diff --git a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx index 51e65b42484..4bf7b572392 100644 --- a/src/components/views/dialogs/spotlight/SpotlightDialog.tsx +++ b/src/components/views/dialogs/spotlight/SpotlightDialog.tsx @@ -480,12 +480,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", @@ -497,9 +497,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(); }; @@ -555,7 +556,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"); }} endAdornment={} {...ariaProperties} @@ -603,7 +604,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 (