Run the tag selection behaviour through the prototype store too

This commit is contained in:
Travis Ralston 2020-08-31 10:22:29 -06:00
parent 724e3f6905
commit 133f981fa8
2 changed files with 10 additions and 20 deletions

View file

@ -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<IState> {
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,
});
}
}
}

View file

@ -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;