diff options
Diffstat (limited to 'webapp/stores')
-rw-r--r-- | webapp/stores/channel_store.jsx | 17 | ||||
-rw-r--r-- | webapp/stores/suggestion_store.jsx | 8 |
2 files changed, 23 insertions, 2 deletions
diff --git a/webapp/stores/channel_store.jsx b/webapp/stores/channel_store.jsx index 13a5c4574..136423d45 100644 --- a/webapp/stores/channel_store.jsx +++ b/webapp/stores/channel_store.jsx @@ -263,6 +263,12 @@ class ChannelStoreClass extends EventEmitter { }); } + setUnreadCountsByCurrentMembers() { + Object.keys(this.myChannelMembers).forEach((key) => { + this.setUnreadCountByChannel(this.myChannelMembers[key].channel_id); + }); + } + setUnreadCountsByChannels(channels) { channels.forEach((c) => { this.setUnreadCountByChannel(c.id); @@ -368,6 +374,15 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => { ChannelStore.setUnreadCountsByMembers(action.members); ChannelStore.emitChange(); break; + case ActionTypes.RECEIVED_CHANNEL_MEMBER: + ChannelStore.storeMyChannelMember(action.member); + currentId = ChannelStore.getCurrentId(); + if (currentId && window.isActive) { + ChannelStore.resetCounts(currentId); + } + ChannelStore.setUnreadCountsByCurrentMembers(); + ChannelStore.emitChange(); + break; case ActionTypes.RECEIVED_MORE_CHANNELS: ChannelStore.storeMoreChannels(action.channels); ChannelStore.emitChange(); @@ -385,4 +400,4 @@ ChannelStore.dispatchToken = AppDispatcher.register((payload) => { } }); -export default ChannelStore;
\ No newline at end of file +export default ChannelStore; diff --git a/webapp/stores/suggestion_store.jsx b/webapp/stores/suggestion_store.jsx index 75221421f..39bea0b0c 100644 --- a/webapp/stores/suggestion_store.jsx +++ b/webapp/stores/suggestion_store.jsx @@ -121,6 +121,11 @@ class SuggestionStore extends EventEmitter { } addSuggestions(id, terms, items, component, matchedPretext) { + if (!this.getPretext(id).endsWith(matchedPretext)) { + // These suggestions are out of date since the pretext has changed + return; + } + const suggestion = this.suggestions.get(id); suggestion.terms.push(...terms); @@ -218,7 +223,7 @@ class SuggestionStore extends EventEmitter { } handleEventPayload(payload) { - const {type, id, ...other} = payload.action; // eslint-disable-line no-use-before-define + const {type, id, ...other} = payload.action; switch (type) { case ActionTypes.SUGGESTION_PRETEXT_CHANGED: @@ -243,6 +248,7 @@ class SuggestionStore extends EventEmitter { this.emitSuggestionsChanged(id); break; case ActionTypes.SUGGESTION_CLEAR_SUGGESTIONS: + this.setPretext(id, ''); this.clearSuggestions(id); this.clearSelection(id); this.emitSuggestionsChanged(id); |