diff --git a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx index f14d29d8ca..a29adc151c 100644 --- a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx +++ b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx @@ -479,12 +479,12 @@ const SpotlightDialog: React.FC = ({ initialText = "", initialFilter = n // eslint-disable-next-line }, [results, filter]); - const viewRoom = (roomId: string, persist = false, viaKeyboard = false) => { + const viewRoom = (room: {roomId: string, roomAlias?: string}, persist = false, viaKeyboard = false) => { if (persist) { const recents = new Set(SettingsStore.getValue("SpotlightSearch.recentSearches", null).reverse()); // remove & add the room to put it at the end - recents.delete(roomId); - recents.add(roomId); + recents.delete(room.roomId); + recents.add(room.roomId); SettingsStore.setValue( "SpotlightSearch.recentSearches", @@ -496,9 +496,10 @@ const SpotlightDialog: React.FC = ({ initialText = "", initialFilter = n defaultDispatcher.dispatch({ action: Action.ViewRoom, - room_id: roomId, metricsTrigger: "WebUnifiedSearch", metricsViaKeyboard: viaKeyboard, + room_id: room.roomId, + room_alias: room.roomAlias, }); onFinished(); }; @@ -551,7 +552,7 @@ const SpotlightDialog: React.FC = ({ initialText = "", initialFilter = n id={`mx_SpotlightDialog_button_result_${result.room.roomId}`} key={`${Section[result.section]}-${result.room.roomId}`} onClick={(ev) => { - viewRoom(result.room.roomId, true, ev?.type !== "click"); + viewRoom({ roomId: result.room.roomId }, true, ev?.type !== "click"); }} {...ariaProperties} > @@ -598,7 +599,11 @@ const SpotlightDialog: React.FC = ({ initialText = "", initialFilter = n if (isPublicRoomResult(result)) { const clientRoom = cli.getRoom(result.publicRoom.room_id); const listener = (ev) => { - viewRoom(result.publicRoom.room_id, true, ev.type !== "click"); + const { publicRoom } = result; + viewRoom({ + roomAlias: publicRoom.canonical_alias || publicRoom.aliases?.[0], + roomId: publicRoom.room_id, + }, true, ev.type !== "click"); }; return (