From ee25df7e5545ad3f4d6817b967a0bcea6e6e398d Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Mon, 20 Jul 2015 12:54:13 -0700
Subject: Added message persistance on closing RHS/switching to another comment
 thread. Similar to the center pane and channels, switching comment threads
 won't delete entered but unsent text/media in the RHS

---
 web/react/stores/post_store.jsx | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

(limited to 'web/react/stores/post_store.jsx')

diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx
index 5280bfe08..fe683c1e8 100644
--- a/web/react/stores/post_store.jsx
+++ b/web/react/stores/post_store.jsx
@@ -136,19 +136,23 @@ var PostStore = assign({}, EventEmitter.prototype, {
   },
   storeCurrentDraft: function(draft) {
     var channel_id = ChannelStore.getCurrentId();
-    var user_id = UserStore.getCurrentId();
-    BrowserStore.setItem("draft_" + channel_id + "_" + user_id, draft);
+    BrowserStore.setItem("draft_" + channel_id, draft);
   },
   getCurrentDraft: function() {
     var channel_id = ChannelStore.getCurrentId();
-    var user_id = UserStore.getCurrentId();
-    return BrowserStore.getItem("draft_" + channel_id + "_" + user_id);
+    return BrowserStore.getItem("draft_" + channel_id);
   },
-  storeDraft: function(channel_id, user_id, draft) {
-    BrowserStore.setItem("draft_" + channel_id + "_" + user_id, draft);
+  storeDraft: function(channel_id, draft) {
+    BrowserStore.setItem("draft_" + channel_id, draft);
   },
-  getDraft: function(channel_id, user_id) {
-    return BrowserStore.getItem("draft_" + channel_id + "_" + user_id);
+  getDraft: function(channel_id) {
+    return BrowserStore.getItem("draft_" + channel_id);
+  },
+  storeCommentDraft: function(parent_post_id, draft) {
+    BrowserStore.setItem("comment_draft_" + parent_post_id, draft);
+  },
+  getCommentDraft: function(parent_post_id) {
+    return BrowserStore.getItem("comment_draft_" + parent_post_id);
   },
   clearDraftUploads: function() {
       BrowserStore.actionOnItemsWithPrefix("draft_", function (key, value) {
@@ -157,6 +161,14 @@ var PostStore = assign({}, EventEmitter.prototype, {
               BrowserStore.setItem(key, value);
           }
       });
+  },
+  clearCommentDraftUploads: function() {
+    BrowserStore.actionOnItemsWithPrefix("comment_draft_", function (key, value) {
+      if (value) {
+        value.uploadsInProgress = 0;
+        BrowserStore.setItem(key, value);
+      }
+    });
   }
 });
 
-- 
cgit v1.2.3-1-g7c22

