forked from zamandalee/Leeway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete message actions and api_util necessary for live messaging
- Loading branch information
1 parent
c0f1506
commit 5e112f7
Showing
2 changed files
with
28 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); |
11 changes: 5 additions & 6 deletions
11
frontend/util/messageable_api_util.js → frontend/util/message_api_util.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}` | ||
// }); |