summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeraLyu <lvroyce0210@gmail.com>2017-04-18 23:47:27 +0800
committerCorey Hulen <corey@hulen.com>2017-04-18 08:47:27 -0700
commit8aab290d10cc7cdd864cebbd463044abfa2d2aea (patch)
tree24eb7d61bd19e648c0a9c916eb673190b5ec0f63
parentd5ae46c96cc837d13155ca81ca2bf7317d282b61 (diff)
downloadchat-8aab290d10cc7cdd864cebbd463044abfa2d2aea.tar.gz
chat-8aab290d10cc7cdd864cebbd463044abfa2d2aea.tar.bz2
chat-8aab290d10cc7cdd864cebbd463044abfa2d2aea.zip
PLT-6240: Remove own pinned post from RHS when removed from channel (#6098)
Dispatch REMOVE_POST event after successfully initiating delete post, others get informed by websocket event and will mark the msg as deleted but not delete from RHS.
-rw-r--r--webapp/actions/post_actions.jsx8
-rw-r--r--webapp/stores/search_store.jsx17
2 files changed, 19 insertions, 6 deletions
diff --git a/webapp/actions/post_actions.jsx b/webapp/actions/post_actions.jsx
index 5319a00c6..266370f60 100644
--- a/webapp/actions/post_actions.jsx
+++ b/webapp/actions/post_actions.jsx
@@ -11,6 +11,7 @@ import {loadStatusesForChannel} from 'actions/status_actions.jsx';
import {loadNewDMIfNeeded, loadNewGMIfNeeded} from 'actions/user_actions.jsx';
import {trackEvent} from 'actions/diagnostics_actions.jsx';
import {sendDesktopNotification} from 'actions/notification_actions.jsx';
+import * as GlobalActions from 'actions/global_actions.jsx';
import Client from 'client/web_client.jsx';
import * as AsyncClient from 'utils/async_client.jsx';
@@ -431,11 +432,6 @@ export function updatePost(post, success, isPost) {
});
}
-export function removePostFromStore(post) {
- PostStore.removePost(post);
- PostStore.emitChange();
-}
-
export function emitEmojiPosted(emoji) {
AppDispatcher.handleServerAction({
type: ActionTypes.EMOJI_POSTED,
@@ -448,7 +444,7 @@ export function deletePost(channelId, post, success, error) {
channelId,
post.id,
() => {
- removePostFromStore(post);
+ GlobalActions.emitRemovePost(post);
if (post.id === PostStore.getSelectedPostId()) {
AppDispatcher.handleServerAction({
type: ActionTypes.RECEIVED_POST_SELECTED,
diff --git a/webapp/stores/search_store.jsx b/webapp/stores/search_store.jsx
index 62cc5635b..2ccf02f94 100644
--- a/webapp/stores/search_store.jsx
+++ b/webapp/stores/search_store.jsx
@@ -133,6 +133,19 @@ class SearchStoreClass extends EventEmitter {
});
}
}
+
+ removePost(post) {
+ const results = this.getSearchResults();
+ if (results == null) {
+ return;
+ }
+
+ const index = results.order.indexOf(post.id);
+ if (index > -1) {
+ delete results.posts[post.id];
+ results.order.splice(index, 1);
+ }
+ }
}
var SearchStore = new SearchStoreClass();
@@ -171,6 +184,10 @@ SearchStore.dispatchToken = AppDispatcher.register((payload) => {
SearchStore.togglePinPost(action.reaction, false);
SearchStore.emitSearchChange();
break;
+ case ActionTypes.REMOVE_POST:
+ SearchStore.removePost(action.post);
+ SearchStore.emitSearchChange();
+ break;
default:
}
});