From fa0f704b567701ff9089934ad118722c98afeb85 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 8 May 2020 00:05:16 +0100 Subject: [PATCH] clear tag panel selection if the community selected is left Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/stores/GroupStore.js | 6 ++++++ src/stores/TagOrderStore.js | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/stores/GroupStore.js b/src/stores/GroupStore.js index 6aad6aeaec..78a144f755 100644 --- a/src/stores/GroupStore.js +++ b/src/stores/GroupStore.js @@ -18,6 +18,7 @@ import EventEmitter from 'events'; import { groupMemberFromApiObject, groupRoomFromApiObject } from '../groups'; import FlairStore from './FlairStore'; import {MatrixClientPeg} from '../MatrixClientPeg'; +import dis from '../dispatcher'; function parseMembersResponse(response) { return response.chunk.map((apiMember) => groupMemberFromApiObject(apiMember)); @@ -295,6 +296,11 @@ class GroupStore extends EventEmitter { } leaveGroup(groupId) { + // ensure the tag panel filter is cleared if the group was selected + dis.dispatch({ + action: "deselect_tags", + tag: groupId, + }); return MatrixClientPeg.get().leaveGroup(groupId) // The user should now not be able to access group settings .then(this._fetchResource.bind(this, this.STATE_KEY.Summary, groupId)) diff --git a/src/stores/TagOrderStore.js b/src/stores/TagOrderStore.js index 6d03a2b289..c05728e497 100644 --- a/src/stores/TagOrderStore.js +++ b/src/stores/TagOrderStore.js @@ -168,9 +168,16 @@ class TagOrderStore extends Store { } break; case 'deselect_tags': - this._setState({ - selectedTags: [], - }); + if (payload.tag) { + // if a tag is passed, only deselect that tag + this._setState({ + selectedTags: this._state.selectedTags.filter(tag => tag !== payload.tag), + }); + } else { + this._setState({ + selectedTags: [], + }); + } Analytics.trackEvent('FilterStore', 'deselect_tags'); break; case 'on_client_not_viable':