From 59185babdc7acc950dd7c671404c1322e5b15333 Mon Sep 17 00:00:00 2001
From: VeraLyu <lvroyce0210@gmail.com>
Date: Thu, 13 Apr 2017 05:28:35 +0800
Subject: PLT-4176: Remain RHS pin post unchanged after channel switching
 (#6038)

Prevent changes to search_store after switched channel so that
RHS pin posts can continue to display previous content.
---
 webapp/stores/search_store.jsx | 9 +++++++++
 1 file changed, 9 insertions(+)

(limited to 'webapp/stores/search_store.jsx')

diff --git a/webapp/stores/search_store.jsx b/webapp/stores/search_store.jsx
index 97e6a3b85..62cc5635b 100644
--- a/webapp/stores/search_store.jsx
+++ b/webapp/stores/search_store.jsx
@@ -5,6 +5,8 @@ import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
 import EventEmitter from 'events';
 
 import Constants from 'utils/constants.jsx';
+import ChannelStore from 'stores/channel_store.jsx';
+
 var ActionTypes = Constants.ActionTypes;
 
 var CHANGE_EVENT = 'change';
@@ -140,6 +142,13 @@ SearchStore.dispatchToken = AppDispatcher.register((payload) => {
 
     switch (action.type) {
     case ActionTypes.RECEIVED_SEARCH:
+        if (SearchStore.getIsPinnedPosts() === action.is_pinned_posts &&
+            action.is_pinned_posts === true &&
+            SearchStore.getSearchResults().posts &&
+            ChannelStore.getCurrentId() !== Object.values(SearchStore.getSearchResults().posts)[0].channel_id) {
+            // ignore pin posts update after switch to a new channel
+            return;
+        }
         SearchStore.storeSearchResults(action.results, action.is_mention_search, action.is_flagged_posts, action.is_pinned_posts);
         SearchStore.emitSearchChange();
         break;
-- 
cgit v1.2.3-1-g7c22

