From 133f981fa8cb4b1efd55c4263e70e9995c3f6c39 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 31 Aug 2020 10:22:29 -0600 Subject: [PATCH] Run the tag selection behaviour through the prototype store too --- src/stores/CommunityPrototypeStore.ts | 10 ++++++++++ src/stores/TagOrderStore.js | 20 -------------------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/stores/CommunityPrototypeStore.ts b/src/stores/CommunityPrototypeStore.ts index 1bc0a46376..501ebfde17 100644 --- a/src/stores/CommunityPrototypeStore.ts +++ b/src/stores/CommunityPrototypeStore.ts @@ -26,6 +26,7 @@ import FlairStore from "./FlairStore"; import TagOrderStore from "./TagOrderStore"; import { MatrixClientPeg } from "../MatrixClientPeg"; import GroupStore from "./GroupStore"; +import dis from "../dispatcher/dispatcher"; interface IState { // nothing of value - we use account data @@ -111,6 +112,15 @@ export class CommunityPrototypeStore extends AsyncStoreWithClient { if (payload.event_type.startsWith("im.vector.group_info.")) { this.emit(UPDATE_EVENT, payload.event_type.substring("im.vector.group_info.".length)); } + } else if (payload.action === "select_tag") { + // Automatically select the general chat when switching communities + const chat = this.getGeneralChat(payload.tag); + if (chat) { + dis.dispatch({ + action: 'view_room', + room_id: chat.roomId, + }); + } } } diff --git a/src/stores/TagOrderStore.js b/src/stores/TagOrderStore.js index 3dfdc5feaf..2b72a963b0 100644 --- a/src/stores/TagOrderStore.js +++ b/src/stores/TagOrderStore.js @@ -166,26 +166,6 @@ class TagOrderStore extends Store { selectedTags: newTags, }); - if (!allowMultiple && newTags.length === 1) { - // We're in prototype behaviour: select the general chat for the community - // XXX: This is duplicated with the CommunityPrototypeStore as a cyclical reference - const rooms = GroupStore.getGroupRooms(newTags[0]) - .map(r => MatrixClientPeg.get().getRoom(r.roomId)) - .filter(r => !!r); - let chat = rooms.find(r => { - const idState = r.currentState.getStateEvents("im.vector.general_chat", ""); - if (!idState || idState.getContent()['groupId'] !== newTags[0]) return false; - return true; - }); - if (!chat) chat = rooms[0]; - if (chat) { - dis.dispatch({ - action: 'view_room', - room_id: chat.roomId, - }); - } - } - Analytics.trackEvent('FilterStore', 'select_tag'); } break;