summaryrefslogtreecommitdiffstats
path: root/web/react/stores/post_store.jsx
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-08-11 09:41:18 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-08-11 09:41:18 -0400
commit17b05f705f910429ece1ca6c64ec56bf89dd014b (patch)
treef33d4ccc0661cba6076e0865def0be6eb2359e8f /web/react/stores/post_store.jsx
parent6ec1b7a8b3aad12bb337b6751a7859349aa03cf6 (diff)
downloadchat-17b05f705f910429ece1ca6c64ec56bf89dd014b.tar.gz
chat-17b05f705f910429ece1ca6c64ec56bf89dd014b.tar.bz2
chat-17b05f705f910429ece1ca6c64ec56bf89dd014b.zip
Changed PostStore.getDraft/getCommentDraft to return an empty draft instead of null when no draft is found
Diffstat (limited to 'web/react/stores/post_store.jsx')
-rw-r--r--web/react/stores/post_store.jsx9
1 files changed, 6 insertions, 3 deletions
diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx
index 044e7b300..9ebdf734c 100644
--- a/web/react/stores/post_store.jsx
+++ b/web/react/stores/post_store.jsx
@@ -132,25 +132,28 @@ var PostStore = assign({}, EventEmitter.prototype, {
getSearchTerm: function getSearchTerm() {
return BrowserStore.getItem('search_term');
},
+ getEmptyDraft: function getEmptyDraft(draft) {
+ return {message: '', uploadsInProgress: [], previews: []};
+ },
storeCurrentDraft: function storeCurrentDraft(draft) {
var channelId = ChannelStore.getCurrentId();
BrowserStore.setItem('draft_' + channelId, draft);
},
getCurrentDraft: function getCurrentDraft() {
var channelId = ChannelStore.getCurrentId();
- return BrowserStore.getItem('draft_' + channelId);
+ return PostStore.getDraft(channelId);
},
storeDraft: function storeDraft(channelId, draft) {
BrowserStore.setItem('draft_' + channelId, draft);
},
getDraft: function getDraft(channelId) {
- return BrowserStore.getItem('draft_' + channelId);
+ return BrowserStore.getItem('draft_' + channelId, PostStore.getEmptyDraft());
},
storeCommentDraft: function storeCommentDraft(parentPostId, draft) {
BrowserStore.setItem('comment_draft_' + parentPostId, draft);
},
getCommentDraft: function getCommentDraft(parentPostId) {
- return BrowserStore.getItem('comment_draft_' + parentPostId);
+ return BrowserStore.getItem('comment_draft_' + parentPostId, PostStore.getEmptyDraft());
},
clearDraftUploads: function clearDraftUploads() {
BrowserStore.actionOnItemsWithPrefix('draft_', function clearUploads(key, value) {