From 6009d1c176a6244a40b4fa26597c9d1ff272fadb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 17 Oct 2022 10:58:46 +0100 Subject: [PATCH] Remove deprecated `m.room.aliases` references (#9431) * Remove deprecated `m.room.aliases` references * Update SlashCommands.tsx --- src/SlashCommands.tsx | 17 ++++++----------- src/Unread.ts | 1 - test/Unread-test.ts | 1 - 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/SlashCommands.tsx b/src/SlashCommands.tsx index a5661876dc..bbd936ce75 100644 --- a/src/SlashCommands.tsx +++ b/src/SlashCommands.tsx @@ -711,7 +711,7 @@ export const Commands = [ runFn: function(roomId, args) { const cli = MatrixClientPeg.get(); - let targetRoomId; + let targetRoomId: string; if (args) { const matches = args.match(/^(\S+)$/); if (matches) { @@ -725,16 +725,11 @@ export const Commands = [ // Try to find a room with this alias const rooms = cli.getRooms(); for (let i = 0; i < rooms.length; i++) { - const aliasEvents = rooms[i].currentState.getStateEvents('m.room.aliases'); - for (let j = 0; j < aliasEvents.length; j++) { - const aliases = aliasEvents[j].getContent().aliases || []; - for (let k = 0; k < aliases.length; k++) { - if (aliases[k] === roomAlias) { - targetRoomId = rooms[i].roomId; - break; - } - } - if (targetRoomId) break; + if (rooms[i].getCanonicalAlias() === roomAlias || + rooms[i].getAltAliases().includes(roomAlias) + ) { + targetRoomId = rooms[i].roomId; + break; } if (targetRoomId) break; } diff --git a/src/Unread.ts b/src/Unread.ts index b9b3409c66..1804ddefb7 100644 --- a/src/Unread.ts +++ b/src/Unread.ts @@ -42,7 +42,6 @@ export function eventTriggersUnreadCount(ev: MatrixEvent): boolean { case EventType.RoomThirdPartyInvite: case EventType.CallAnswer: case EventType.CallHangup: - case EventType.RoomAliases: case EventType.RoomCanonicalAlias: case EventType.RoomServerAcl: case M_BEACON.name: diff --git a/test/Unread-test.ts b/test/Unread-test.ts index 1c1c469cba..e96c134931 100644 --- a/test/Unread-test.ts +++ b/test/Unread-test.ts @@ -103,7 +103,6 @@ describe('eventTriggersUnreadCount()', () => { EventType.RoomThirdPartyInvite, EventType.CallAnswer, EventType.CallHangup, - EventType.RoomAliases, EventType.RoomCanonicalAlias, EventType.RoomServerAcl, ];