-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converting the last action left over and adding a new util that uses the function found in MessageStore for generating the message data.
- Loading branch information
1 parent
6f8cf22
commit 58ea141
Showing
2 changed files
with
27 additions
and
26 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,31 +1,15 @@ | ||
/** | ||
* This file is provided by Facebook for testing and evaluation purposes | ||
* only. Facebook reserves all rights not expressly granted. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN | ||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
var alt = require('../alt') | ||
|
||
var ChatAppDispatcher = require('../dispatcher/ChatAppDispatcher'); | ||
var ChatConstants = require('../constants/ChatConstants'); | ||
var ChatWebAPIUtils = require('../utils/ChatWebAPIUtils'); | ||
var MessageStore = require('../stores/MessageStore'); | ||
var ChatWebAPIUtils = require('../utils/ChatWebAPIUtils') | ||
var ChatMessageDataUtils = require('../utils/ChatMessageDataUtils') | ||
|
||
var ActionTypes = ChatConstants.ActionTypes; | ||
class ChatMessageActions { | ||
createMessage(text) { | ||
this.dispatch(text) | ||
|
||
module.exports = { | ||
|
||
createMessage: function(text) { | ||
ChatAppDispatcher.handleViewAction({ | ||
type: ActionTypes.CREATE_MESSAGE, | ||
text: text | ||
}); | ||
var message = MessageStore.getCreatedMessageData(text); | ||
ChatWebAPIUtils.createMessage(message); | ||
var message = ChatMessageDataUtils.getCreatedMessageData(text) | ||
ChatWebAPIUtils.createMessage(message) | ||
} | ||
} | ||
|
||
}; | ||
module.exports = alt.createActions(ChatMessageActions) |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
var ThreadStore = require('../stores/ThreadStore') | ||
|
||
class Chatmessage2Utils { | ||
static getCreatedMessageData(text) { | ||
var timestamp = Date.now() | ||
return { | ||
id: 'm_' + timestamp, | ||
threadID: ThreadStore.getCurrentID(), | ||
authorName: 'Bill', // hard coded for the example | ||
date: new Date(timestamp), | ||
text: text, | ||
isRead: true | ||
} | ||
} | ||
} | ||
|
||
module.exports = Chatmessage2Utils |