diff options
author | Joram Wilander <jwawilander@gmail.com> | 2017-08-10 07:33:52 -0400 |
---|---|---|
committer | George Goldberg <george@gberg.me> | 2017-08-10 12:33:52 +0100 |
commit | 70157ef0e3bc0e8d6cc96ae41acdd204353d2269 (patch) | |
tree | 56e451bea69e11b55cf817aeb6e9128d95362750 /webapp/stores/search_store.jsx | |
parent | 58b2bcd90794d7584bf2aa422c16d82e4156f8a4 (diff) | |
download | chat-70157ef0e3bc0e8d6cc96ae41acdd204353d2269.tar.gz chat-70157ef0e3bc0e8d6cc96ae41acdd204353d2269.tar.bz2 chat-70157ef0e3bc0e8d6cc96ae41acdd204353d2269.zip |
Fix pinned posts not updating when list empty (#7164)
Diffstat (limited to 'webapp/stores/search_store.jsx')
-rw-r--r-- | webapp/stores/search_store.jsx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/webapp/stores/search_store.jsx b/webapp/stores/search_store.jsx index dd9b6dbdf..7db0ed92a 100644 --- a/webapp/stores/search_store.jsx +++ b/webapp/stores/search_store.jsx @@ -174,11 +174,14 @@ SearchStore.dispatchToken = AppDispatcher.register((payload) => { var action = payload.action; switch (action.type) { - case ActionTypes.RECEIVED_SEARCH: + case ActionTypes.RECEIVED_SEARCH: { + const results = SearchStore.getSearchResults() || {}; + const posts = Object.values(results.posts || {}); + const channelId = posts.length > 0 ? posts[0].channel_id : ''; 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) { + channelId !== '' && + ChannelStore.getCurrentId() !== channelId) { // ignore pin posts update after switch to a new channel return; } @@ -186,6 +189,7 @@ SearchStore.dispatchToken = AppDispatcher.register((payload) => { SearchStore.storeSearchResults(action.results, action.is_mention_search, action.is_flagged_posts, action.is_pinned_posts); SearchStore.emitSearchChange(); break; + } case ActionTypes.RECEIVED_SEARCH_TERM: if (action.do_search) { // while a search is in progress, hide results from previous search |