Select the general chat for a community when viewing it

This commit is contained in:
Travis Ralston 2020-08-25 21:52:48 -06:00
parent 20c562c208
commit 55001f3193

View file

@ -166,6 +166,25 @@ class TagOrderStore extends Store {
selectedTags: newTags,
});
if (!allowMultiple && newTags.length === 1) {
// We're in prototype behaviour: select the general chat for the community
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;