mirror of https://github.com/vector-im/riot-web
* Prefer using the canonical alias in spotlight search Public rooms on other homeservers are not joinable via the roomId if they haven't been joined by other users on your homeserver. * Ensure we call the action with the room_alias * lint * Drop display * Always provide roomId * Add rationale to room_id, room_alias * whoops Co-authored-by: Michael Telatynski <7t3chguy@gmail.com> Co-authored-by: Will Hunt <will@half-shot.uk> Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>pull/28217/head
parent
7b744cd938
commit
85363efba5
|
@ -479,12 +479,12 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
}, [results, filter]);
|
}, [results, filter]);
|
||||||
|
|
||||||
const viewRoom = (roomId: string, persist = false, viaKeyboard = false) => {
|
const viewRoom = (room: {roomId: string, roomAlias?: string}, persist = false, viaKeyboard = false) => {
|
||||||
if (persist) {
|
if (persist) {
|
||||||
const recents = new Set(SettingsStore.getValue("SpotlightSearch.recentSearches", null).reverse());
|
const recents = new Set(SettingsStore.getValue("SpotlightSearch.recentSearches", null).reverse());
|
||||||
// remove & add the room to put it at the end
|
// remove & add the room to put it at the end
|
||||||
recents.delete(roomId);
|
recents.delete(room.roomId);
|
||||||
recents.add(roomId);
|
recents.add(room.roomId);
|
||||||
|
|
||||||
SettingsStore.setValue(
|
SettingsStore.setValue(
|
||||||
"SpotlightSearch.recentSearches",
|
"SpotlightSearch.recentSearches",
|
||||||
|
@ -496,9 +496,10 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
||||||
|
|
||||||
defaultDispatcher.dispatch<ViewRoomPayload>({
|
defaultDispatcher.dispatch<ViewRoomPayload>({
|
||||||
action: Action.ViewRoom,
|
action: Action.ViewRoom,
|
||||||
room_id: roomId,
|
|
||||||
metricsTrigger: "WebUnifiedSearch",
|
metricsTrigger: "WebUnifiedSearch",
|
||||||
metricsViaKeyboard: viaKeyboard,
|
metricsViaKeyboard: viaKeyboard,
|
||||||
|
room_id: room.roomId,
|
||||||
|
room_alias: room.roomAlias,
|
||||||
});
|
});
|
||||||
onFinished();
|
onFinished();
|
||||||
};
|
};
|
||||||
|
@ -551,7 +552,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
||||||
id={`mx_SpotlightDialog_button_result_${result.room.roomId}`}
|
id={`mx_SpotlightDialog_button_result_${result.room.roomId}`}
|
||||||
key={`${Section[result.section]}-${result.room.roomId}`}
|
key={`${Section[result.section]}-${result.room.roomId}`}
|
||||||
onClick={(ev) => {
|
onClick={(ev) => {
|
||||||
viewRoom(result.room.roomId, true, ev?.type !== "click");
|
viewRoom({ roomId: result.room.roomId }, true, ev?.type !== "click");
|
||||||
}}
|
}}
|
||||||
{...ariaProperties}
|
{...ariaProperties}
|
||||||
>
|
>
|
||||||
|
@ -598,7 +599,11 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
||||||
if (isPublicRoomResult(result)) {
|
if (isPublicRoomResult(result)) {
|
||||||
const clientRoom = cli.getRoom(result.publicRoom.room_id);
|
const clientRoom = cli.getRoom(result.publicRoom.room_id);
|
||||||
const listener = (ev) => {
|
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 (
|
return (
|
||||||
<Option
|
<Option
|
||||||
|
@ -777,7 +782,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
||||||
id={`mx_SpotlightDialog_button_result_${room.room_id}`}
|
id={`mx_SpotlightDialog_button_result_${room.room_id}`}
|
||||||
key={room.room_id}
|
key={room.room_id}
|
||||||
onClick={(ev) => {
|
onClick={(ev) => {
|
||||||
viewRoom(room.room_id, true, ev?.type !== "click");
|
viewRoom({ roomId: room.room_id }, true, ev?.type !== "click");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<BaseAvatar
|
<BaseAvatar
|
||||||
|
@ -967,7 +972,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
||||||
id={`mx_SpotlightDialog_button_recentSearch_${room.roomId}`}
|
id={`mx_SpotlightDialog_button_recentSearch_${room.roomId}`}
|
||||||
key={room.roomId}
|
key={room.roomId}
|
||||||
onClick={(ev) => {
|
onClick={(ev) => {
|
||||||
viewRoom(room.roomId, true, ev?.type !== "click");
|
viewRoom({ roomId: room.roomId }, true, ev?.type !== "click");
|
||||||
}}
|
}}
|
||||||
{...ariaProperties}
|
{...ariaProperties}
|
||||||
>
|
>
|
||||||
|
@ -1008,7 +1013,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
||||||
title={room.name}
|
title={room.name}
|
||||||
key={room.roomId}
|
key={room.roomId}
|
||||||
onClick={(ev) => {
|
onClick={(ev) => {
|
||||||
viewRoom(room.roomId, false, ev.type !== "click");
|
viewRoom({ roomId: room.roomId }, false, ev.type !== "click");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DecoratedRoomAvatar room={room} avatarSize={32} tooltipProps={{ tabIndex: -1 }} />
|
<DecoratedRoomAvatar room={room} avatarSize={32} tooltipProps={{ tabIndex: -1 }} />
|
||||||
|
|
|
@ -26,7 +26,9 @@ import { IOpts } from "../../createRoom";
|
||||||
export interface ViewRoomPayload extends Pick<ActionPayload, "action"> {
|
export interface ViewRoomPayload extends Pick<ActionPayload, "action"> {
|
||||||
action: Action.ViewRoom;
|
action: Action.ViewRoom;
|
||||||
|
|
||||||
// either of room_id or room_alias must be specified
|
// either or both of room_id or room_alias must be specified
|
||||||
|
// where possible, a room_id should be provided with a room_alias as it reduces
|
||||||
|
// the number of API calls required.
|
||||||
room_id?: string;
|
room_id?: string;
|
||||||
room_alias?: string;
|
room_alias?: string;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue