Permalink
Browse files

Converts last action

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...
goatslacker committed Dec 27, 2014
1 parent 6f8cf22 commit 58ea1418ecd2af25b578cd0f4b77c3d4d8631518
Showing with 27 additions and 26 deletions.
  1. +10 −26 examples/chat/js/actions/ChatMessageActionCreators.js
  2. +17 −0 examples/chat/js/utils/ChatMessageDataUtils.js
@@ -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)
@@ -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

0 comments on commit 58ea141

Please sign in to comment.