From 6a191ea3ee5645c750f8a773ee29335b839343b5 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 30 Jun 2020 14:23:00 -0600 Subject: [PATCH] Handle room invites as new rooms We wouldn't have seen them before, so might as well treat them as new instead of tag changes. --- src/stores/room-list/RoomListStore2.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/stores/room-list/RoomListStore2.ts b/src/stores/room-list/RoomListStore2.ts index b4b643687d..497b8e5530 100644 --- a/src/stores/room-list/RoomListStore2.ts +++ b/src/stores/room-list/RoomListStore2.ts @@ -29,6 +29,7 @@ import { IFilterCondition } from "./filters/IFilterCondition"; import { TagWatcher } from "./TagWatcher"; import RoomViewStore from "../RoomViewStore"; import { Algorithm, LIST_UPDATED_EVENT } from "./algorithms/Algorithm"; +import { EffectiveMembership, getEffectiveMembership } from "./membership"; interface IState { tagsEnabled?: boolean; @@ -247,7 +248,9 @@ export class RoomListStore2 extends AsyncStore { } } else if (payload.action === 'MatrixActions.Room.myMembership') { const membershipPayload = (payload); // TODO: Type out the dispatcher types - if (membershipPayload.oldMembership !== "join" && membershipPayload.membership === "join") { + const oldMembership = getEffectiveMembership(membershipPayload.oldMembership); + const newMembership = getEffectiveMembership(membershipPayload.membership); + if (oldMembership !== EffectiveMembership.Join && newMembership === EffectiveMembership.Join) { // TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035 console.log(`[RoomListDebug] Handling new room ${membershipPayload.room.roomId}`); @@ -276,8 +279,15 @@ export class RoomListStore2 extends AsyncStore { return; } + if (oldMembership !== EffectiveMembership.Invite && newMembership === EffectiveMembership.Invite) { + // TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035 + console.log(`[RoomListDebug] Handling invite to ${membershipPayload.room.roomId}`); + await this.handleRoomUpdate(membershipPayload.room, RoomUpdateCause.NewRoom); + return; + } + // If it's not a join, it's transitioning into a different list (possibly historical) - if (membershipPayload.oldMembership !== membershipPayload.membership) { + if (oldMembership !== newMembership) { // TODO: Remove debug: https://github.com/vector-im/riot-web/issues/14035 console.log(`[RoomListDebug] Handling membership change in ${membershipPayload.room.roomId}`); await this.handleRoomUpdate(membershipPayload.room, RoomUpdateCause.PossibleTagChange);