diff --git a/webapp/components/search_results.jsx b/webapp/components/search_results.jsx
index f128245e41..8d50338e02 100644
--- a/webapp/components/search_results.jsx
+++ b/webapp/components/search_results.jsx
@@ -19,7 +19,7 @@ import React from 'react';
import {FormattedMessage, FormattedHTMLMessage} from 'react-intl';
function getStateFromStores() {
- const results = SearchStore.getSearchResults();
+ const results = JSON.parse(JSON.stringify(SearchStore.getSearchResults()));
const channels = new Map();
diff --git a/webapp/components/search_results_item.jsx b/webapp/components/search_results_item.jsx
index 698d68bbaf..d9955a1369 100644
--- a/webapp/components/search_results_item.jsx
+++ b/webapp/components/search_results_item.jsx
@@ -111,42 +111,132 @@ export default class SearchResultsItem extends React.Component {
compactClass = 'post--compact';
}
- let flag;
- let flagFunc;
- let flagVisible = '';
- let flagTooltip = (
-
-
-
- );
- if (this.props.isFlagged) {
- flagVisible = 'visible';
- flagTooltip = (
+ let message;
+ let flagContent;
+ let rhsControls;
+ if (post.state === Constants.POST_DELETED) {
+ message = (
+
+
+
+ );
+ } else {
+ let flag;
+ let flagFunc;
+ let flagVisible = '';
+ let flagTooltip = (
);
- flagFunc = this.unflagPost;
- flag = (
-
+
+
+ );
+ flagFunc = this.unflagPost;
+ flag = (
+
+ );
+ } else {
+ flag = (
+
+ );
+ flagFunc = this.flagPost;
+ }
+
+ flagContent = (
+
+
+ {flag}
+
+
+ );
+
+ rhsControls = (
+
+
+
+
+ {
+ if (Utils.isMobile()) {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_SEARCH,
+ results: null
+ });
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_SEARCH_TERM,
+ term: null,
+ do_search: false,
+ is_mention_search: false
+ });
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_POST_SELECTED,
+ postId: null
+ });
+
+ this.hideSidebar();
+ }
+ this.shrinkSidebar();
+ browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/pl/' + post.id);
+ }
+ }
+ className='search-item__jump'
+ >
+
+
+
+ );
+
+ message = (
+
);
- } else {
- flag = (
-
- );
- flagFunc = this.flagPost;
}
return (
@@ -187,75 +277,12 @@ export default class SearchResultsItem extends React.Component {
minute='2-digit'
/>
-
-
- {flag}
-
-
-
-
-
-
-
- {
- if (Utils.isMobile()) {
- AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_SEARCH,
- results: null
- });
-
- AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_SEARCH_TERM,
- term: null,
- do_search: false,
- is_mention_search: false
- });
-
- AppDispatcher.handleServerAction({
- type: ActionTypes.RECEIVED_POST_SELECTED,
- postId: null
- });
-
- this.hideSidebar();
- }
- this.shrinkSidebar();
- browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/pl/' + post.id);
- }
- }
- className='search-item__jump'
- >
-
-
+ {flagContent}
+ {rhsControls}
diff --git a/webapp/components/suggestion/suggestion_box.jsx b/webapp/components/suggestion/suggestion_box.jsx
index eeae5ba28b..3a8cd65cff 100644
--- a/webapp/components/suggestion/suggestion_box.jsx
+++ b/webapp/components/suggestion/suggestion_box.jsx
@@ -39,7 +39,8 @@ export default class SuggestionBox extends React.Component {
componentWillReceiveProps(nextProps) {
// Clear any suggestions when the SuggestionBox is cleared
if (nextProps.value === '' && this.props.value !== nextProps.value) {
- GlobalActions.emitClearSuggestions(this.suggestionId);
+ // TODO - Find a better way to not "dispatch during dispatch"
+ setTimeout(() => GlobalActions.emitClearSuggestions(this.suggestionId), 1);
}
}
diff --git a/webapp/stores/search_store.jsx b/webapp/stores/search_store.jsx
index d1458ceed3..46a086ddb1 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:
}
});