var dispatcher = require('../dispatcher');
var isObject = require("lodash/lang/isObject");

/**
 * Add a message.
 * @param {object} message - The message object.
 */
function addMessage(message){
  dispatcher.handleServerAction({
    data: {message: message},
    type: 'push'
  });
}

/**
 * Add an error message.
 * @param {object} message - The message content.
 */
function addErrorMessage(message){
  message = parseStringMessage(message);
  message.type = 'error';
  addMessage(message);
}
/**
 * Add a warning message.
 * @param {object} message - The message content.
 */
function addWarningMessage(message){
  message = parseStringMessage(message);
  message.type = 'warning';
  addMessage(message);
}

/**
 * Add an information message.
 * @param {object} message - The message content.
 */
function addInformationMessage(message){
  message = parseStringMessage(message);
  message.type = 'info';
  addMessage(message);
}

/**
 * Add a success message.
 * @param {object} message - The message content.
 */
function addSuccessMessage(message){
  message = parseStringMessage(message);
  message.type = 'success';
  addMessage(message);
}

function clearMessages(){
  dispatcher.handleServerAction({data: {messages: {}}, type: 'clear'});
}

function parseStringMessage(message) {
    if(!isObject(message)) {
        message = {content: message};
    }
    return message;
}

module.exports = {
  addMessage: addMessage,
  addWarningMessage: addWarningMessage,
  addInformationMessage: addInformationMessage,
  addErrorMessage: addErrorMessage,
  addSuccessMessage: addSuccessMessage,
  clearMessages: clearMessages,
  builtInStore: require('./built-in-store')
};

@@ -42,22 +42,22 @@
 ;%0Avar is
-Object
+String
  = requi
@@ -59,17 +59,17 @@
 require(
-%22
+'
 lodash/l
@@ -78,17 +78,343 @@
 g/is
-Object%22);
+String');%0A%0A/**%0A * Transform the message into objet if it is a string.%0A * @param %7B%5Bstring, object%5D%7D message - The message to display (object or string).%0A * @returns %7Bobject%7D - The well constructed message.%0A */%0Afunction _parseString(message) %7B%0A    if(isString(message)) %7B%0A        message = %7Bcontent: message%7D;%0A    %7D%0A    return message;%0A%7D
 %0A%0A/*
@@ -728,32 +728,33 @@
 e)%7B%0A  message = 
+_
 parseStringMessa
@@ -740,39 +740,32 @@
 e = _parseString
-Message
 (message);%0A  mes
@@ -935,32 +935,33 @@
 e)%7B%0A  message = 
+_
 parseStringMessa
@@ -947,39 +947,32 @@
 e = _parseString
-Message
 (message);%0A  mes
@@ -1154,32 +1154,33 @@
 e)%7B%0A  message = 
+_
 parseStringMessa
@@ -1166,39 +1166,32 @@
 e = _parseString
-Message
 (message);%0A  mes
@@ -1369,16 +1369,17 @@
 ssage = 
+_
 parseStr
@@ -1373,39 +1373,32 @@
 e = _parseString
-Message
 (message);%0A  mes
@@ -1551,141 +1551,8 @@
 %0A%7D%0A%0A
-function parseStringMessage(message) %7B%0A    if(!isObject(message)) %7B%0A        message = %7Bcontent: message%7D;%0A    %7D%0A    return message;%0A%7D
 %0A%0Amo

Change the writing of the addMessage*.