Skip to content

Commit

Permalink
Complete message actions and api_util necessary for live messaging
Browse files Browse the repository at this point in the history
  • Loading branch information
zamandalee committed Aug 10, 2018
1 parent c0f1506 commit 5e112f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
26 changes: 23 additions & 3 deletions frontend/actions/messageable_actions.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
import * as WorkspaceApiUtil from '../util/workspace_api_util';
import * as MessageApiUtil from '../util/message_api_util';

export const CREATE_MESSAGE = 'CREATE_MESSAGE';
export const RECEIVE_MESSAGE = 'CREATE_MESSAGE';
export const RECEIVE_MESSAGES = 'CREATE_MESSAGES';
export const CREATE_MESSAGE = 'CREATE_MESSAGE';
export const REMOVE_MESSAGE = 'REMOVE_MESSAGE';

export const createMessage = (message) => {
return dispatch => {
return WorkspaceApiUtil.createMessage(message).then( newMessage => {
return MessageApiUtil.createMessage(message).then( newMessage => {
return dispatch(receiveMessage(newMessage));
});
};
};

// export const deleteMessage = (id) => {
// return dispatch => {
// return MessageApiUtil.deleteMessage(id).then( message => {
// return dispatch(removeMessage(message));
// });
// };
// };

export const receiveMessage = (message) => ({
type: RECEIVE_MESSAGE,
message
});

export const receiveMessages = (messages) => ({
type: RECEIVE_MESSAGES,
messages
});

export const removeMessage = (message) => ({
type: REMOVE_MESSAGE,
message
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@






export const createMessage = (message) => ({
method: 'POST',
url: `/api/channels/${message.messageable_id}/messages`
});

// export const deleteMessage = (id) => ({
// method: 'DELETE',
// url: `/api/channels/:channel_id/messages/${id}`
// });

0 comments on commit 5e112f7

Please sign in to comment.