summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorVeraLyu <lvroyce0210@gmail.com>2017-04-13 04:23:33 +0800
committerHarrison Healey <harrisonmhealey@gmail.com>2017-04-12 16:23:33 -0400
commit03502cf73b8513a40877b1ac5726523974661d4d (patch)
treedae083a00534cfcc4dc9f52ebb533d82a9a17de5 /webapp
parenta10ad339d10a78779d0eefce6c4e94a0836bc6f4 (diff)
downloadchat-03502cf73b8513a40877b1ac5726523974661d4d.tar.gz
chat-03502cf73b8513a40877b1ac5726523974661d4d.tar.bz2
chat-03502cf73b8513a40877b1ac5726523974661d4d.zip
PLT-6155: Keep pin badges in RHS consistent with that in center (#6018)
Sync search store when recieving pin/unpin event to keep pin badges in RHS consistent with that in center channel.
Diffstat (limited to 'webapp')
-rw-r--r--webapp/stores/search_store.jsx22
-rw-r--r--webapp/utils/async_client.jsx6
2 files changed, 26 insertions, 2 deletions
diff --git a/webapp/stores/search_store.jsx b/webapp/stores/search_store.jsx
index d94c48f8a..97e6a3b85 100644
--- a/webapp/stores/search_store.jsx
+++ b/webapp/stores/search_store.jsx
@@ -117,6 +117,20 @@ class SearchStoreClass extends EventEmitter {
});
}
}
+
+ togglePinPost(postId, isPinned) {
+ const results = this.getSearchResults();
+ if (results == null) {
+ return;
+ }
+
+ if (postId in results.posts) {
+ const post = results.posts[postId];
+ results.posts[postId] = Object.assign({}, post, {
+ is_pinned: isPinned
+ });
+ }
+ }
}
var SearchStore = new SearchStoreClass();
@@ -140,6 +154,14 @@ SearchStore.dispatchToken = AppDispatcher.register((payload) => {
SearchStore.deletePost(action.post);
SearchStore.emitSearchChange();
break;
+ case ActionTypes.RECEIVED_POST_PINNED:
+ SearchStore.togglePinPost(action.reaction, true);
+ SearchStore.emitSearchChange();
+ break;
+ case ActionTypes.RECEIVED_POST_UNPINNED:
+ SearchStore.togglePinPost(action.reaction, false);
+ SearchStore.emitSearchChange();
+ break;
default:
}
});
diff --git a/webapp/utils/async_client.jsx b/webapp/utils/async_client.jsx
index 25c043b63..abc1017fa 100644
--- a/webapp/utils/async_client.jsx
+++ b/webapp/utils/async_client.jsx
@@ -1606,7 +1606,8 @@ export function pinPost(channelId, reaction) {
// the "post_edited" websocket event take cares of updating the posts
// the action below is mostly dispatched for the RHS to update
AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_POST_PINNED
+ type: ActionTypes.RECEIVED_POST_PINNED,
+ reaction
});
},
(err) => {
@@ -1623,7 +1624,8 @@ export function unpinPost(channelId, reaction) {
// the "post_edited" websocket event take cares of updating the posts
// the action below is mostly dispatched for the RHS to update
AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_POST_UNPINNED
+ type: ActionTypes.RECEIVED_POST_UNPINNED,
+ reaction
});
},
(err) => {