|
@@ -1,5 +1,7 @@
|
|
|
const ADD_POST = 'ADD-POST';
|
|
|
const UPDATE_NEW_POST_TEXT = 'UPDATE-NEW-POST-TEXT';
|
|
|
+const UPDATE_NEW_MESSAGE_BODY = 'UPDATE-NEW-MESSAGE-BODY';
|
|
|
+const SEND_MESSAGE = 'SEND-MESSAGE';
|
|
|
|
|
|
let store = {
|
|
|
_state: {
|
|
@@ -25,6 +27,7 @@ let store = {
|
|
|
{ id: 2, message: "How is your project?" },
|
|
|
{ id: 3, message: "Looks not ok" },
|
|
|
],
|
|
|
+ newMessageBody: ""
|
|
|
},
|
|
|
},
|
|
|
getState() {
|
|
@@ -46,12 +49,19 @@ let store = {
|
|
|
} else if(action.type === UPDATE_NEW_POST_TEXT) {
|
|
|
this._state.profilePage.newPostText = action.newText;
|
|
|
this._callSubscriber(this._state);
|
|
|
+ } else if(action.type === UPDATE_NEW_MESSAGE_BODY) {
|
|
|
+ this._state.messagesPage.newMessageBody = action.body;
|
|
|
+ this._callSubscriber(this._state);
|
|
|
+ } else if(action.type === SEND_MESSAGE) {
|
|
|
+ let body = this._state.messagesPage.newMessageBody = action.body;
|
|
|
+ this._state.messagesPage.newMessageBody = 0;
|
|
|
+ this._state.messagesPage.newMessageBody.push({ id: 4, message: body });
|
|
|
+ this._callSubscriber(this._state);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
export const addPostActionCreator = () => ({ type: 'ADD-POST' });
|
|
|
-
|
|
|
export const updateNewPostTextActionCreator = (text) => {
|
|
|
return {
|
|
|
type: 'UPDATE-NEW-POST-TEXT',
|
|
@@ -59,4 +69,12 @@ export const updateNewPostTextActionCreator = (text) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+export const sendMessageCreator = () => ({ type: 'SEND-MESSAGE' });
|
|
|
+export const updateNewMessageBodyCreator = (body) => {
|
|
|
+ return {
|
|
|
+ type: 'UPDATE-NEW-MESSAGE-BODY',
|
|
|
+ body: body
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export default store;
|