diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-11-22 09:13:14 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-11-22 09:13:14 -0500 |
commit | 3c65a20f4587da6315d47222b5d9852d7e5ad66f (patch) | |
tree | 734e690a2bbbdc290198dadce3b0deab72b98f74 /webapp/stores/search_store.jsx | |
parent | 48d64f3f68bc861eda3732457b5d24d238cacc53 (diff) | |
download | chat-3c65a20f4587da6315d47222b5d9852d7e5ad66f.tar.gz chat-3c65a20f4587da6315d47222b5d9852d7e5ad66f.tar.bz2 chat-3c65a20f4587da6315d47222b5d9852d7e5ad66f.zip |
Deleted posts now update in search results and flagged posts (#4618)
Diffstat (limited to 'webapp/stores/search_store.jsx')
-rw-r--r-- | webapp/stores/search_store.jsx | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/webapp/stores/search_store.jsx b/webapp/stores/search_store.jsx index d1458ceed..46a086ddb 100644 --- a/webapp/stores/search_store.jsx +++ b/webapp/stores/search_store.jsx @@ -96,6 +96,21 @@ class SearchStoreClass extends EventEmitter { this.isMentionSearch = isMentionSearch; this.isFlaggedPosts = isFlaggedPosts; } + + deletePost(post) { + const results = this.getSearchResults(); + if (results == null) { + return; + } + + if (post.id in results.posts) { + // make sure to copy the post so that component state changes work properly + results.posts[post.id] = Object.assign({}, post, { + state: Constants.POST_DELETED, + file_ids: [] + }); + } + } } var SearchStore = new SearchStoreClass(); @@ -115,6 +130,10 @@ SearchStore.dispatchToken = AppDispatcher.register((payload) => { case ActionTypes.SHOW_SEARCH: SearchStore.emitShowSearch(); break; + case ActionTypes.POST_DELETED: + SearchStore.deletePost(action.post); + SearchStore.emitSearchChange(); + break; default: } }); |