Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 9611cbf

Browse files
authored
Fix people space notification badge not updating for new DM invites (#10849)
* Add regression test * Fix people space notification state not updating for new DM invites
1 parent cb779fe commit 9611cbf

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

src/stores/spaces/SpaceStore.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
765765

766766
const hiddenChildren = new EnhancedMap<string, Set<string>>();
767767
visibleRooms.forEach((room) => {
768-
if (room.getMyMembership() !== "join") return;
768+
if (!["join", "invite"].includes(room.getMyMembership())) return;
769769
this.getParents(room.roomId).forEach((parent) => {
770770
hiddenChildren.getOrCreate(parent.roomId, new Set()).add(room.roomId);
771771
});
@@ -872,10 +872,9 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
872872
}
873873

874874
const notificationStatesToUpdate = [...changeSet];
875-
if (
876-
this.enabledMetaSpaces.includes(MetaSpace.People) &&
877-
userDiff.added.length + userDiff.removed.length + usersChanged.length > 0
878-
) {
875+
// We update the People metaspace even if we didn't detect any changes
876+
// as roomIdsBySpace does not pre-calculate it so we have to assume it could have changed
877+
if (this.enabledMetaSpaces.includes(MetaSpace.People)) {
879878
notificationStatesToUpdate.push(MetaSpace.People);
880879
}
881880
this.updateNotificationStates(notificationStatesToUpdate);

test/stores/SpaceStore-test.ts

+23
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,29 @@ describe("SpaceStore", () => {
672672
});
673673
});
674674

675+
it("should add new DM Invites to the People Space Notification State", async () => {
676+
mkRoom(dm1);
677+
mocked(client.getRoom(dm1)!).getMyMembership.mockReturnValue("join");
678+
mocked(client).getRoom.mockImplementation((roomId) => rooms.find((room) => room.roomId === roomId) || null);
679+
680+
await run();
681+
682+
mkRoom(dm2);
683+
const cliDm2 = client.getRoom(dm2)!;
684+
mocked(cliDm2).getMyMembership.mockReturnValue("invite");
685+
mocked(client).getRoom.mockImplementation((roomId) => rooms.find((room) => room.roomId === roomId) || null);
686+
client.emit(RoomEvent.MyMembership, cliDm2, "invite");
687+
688+
[dm1, dm2].forEach((d) => {
689+
expect(
690+
store
691+
.getNotificationState(MetaSpace.People)
692+
.rooms.map((r) => r.roomId)
693+
.includes(d),
694+
).toBeTruthy();
695+
});
696+
});
697+
675698
describe("hierarchy resolution update tests", () => {
676699
it("updates state when spaces are joined", async () => {
677700
await run();

0 commit comments

Comments
 (0)