From 28bc8010a71d0a73354401ea8cc171310b0ba284 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 16 Sep 2021 11:20:01 +0100 Subject: [PATCH] Say Joining space instead of Joining room where we know its a space --- src/components/structures/SpaceHierarchy.tsx | 37 +++++++++++++------ src/components/views/rooms/RoomPreviewBar.tsx | 2 +- src/i18n/strings/en_EN.json | 1 + src/stores/ThreepidInviteStore.ts | 1 + 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/components/structures/SpaceHierarchy.tsx b/src/components/structures/SpaceHierarchy.tsx index 09099032dc..c5fe2bd139 100644 --- a/src/components/structures/SpaceHierarchy.tsx +++ b/src/components/structures/SpaceHierarchy.tsx @@ -63,7 +63,13 @@ interface IProps { space: Room; initialText?: string; additionalButtons?: ReactNode; - showRoom(cli: MatrixClient, hierarchy: RoomHierarchy, roomId: string, autoJoin?: boolean): void; + showRoom( + cli: MatrixClient, + hierarchy: RoomHierarchy, + roomId: string, + autoJoin?: boolean, + isSpaceRoom?: boolean, + ): void; } interface ITileProps { @@ -72,7 +78,7 @@ interface ITileProps { selected?: boolean; numChildRooms?: number; hasPermissions?: boolean; - onViewRoomClick(autoJoin: boolean): void; + onViewRoomClick(autoJoin: boolean, isSpaceRoom: boolean): void; onToggleClick?(): void; } @@ -98,12 +104,12 @@ const Tile: React.FC = ({ const onPreviewClick = (ev: ButtonEvent) => { ev.preventDefault(); ev.stopPropagation(); - onViewRoomClick(false); + onViewRoomClick(false, room.room_type === RoomType.Space); }; const onJoinClick = (ev: ButtonEvent) => { ev.preventDefault(); ev.stopPropagation(); - onViewRoomClick(true); + onViewRoomClick(true, room.room_type === RoomType.Space); }; let button; @@ -280,7 +286,13 @@ const Tile: React.FC = ({ ; }; -export const showRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: string, autoJoin = false) => { +export const showRoom = ( + cli: MatrixClient, + hierarchy: RoomHierarchy, + roomId: string, + autoJoin = false, + isSpaceRoom = false, +) => { const room = hierarchy.roomMap.get(roomId); // Don't let the user view a room they won't be able to either peek or join: @@ -305,6 +317,7 @@ export const showRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: st avatarUrl: room.avatar_url, // XXX: This logic is duplicated from the JS SDK which would normally decide what the name is. name: room.name || roomAlias || _t("Unnamed room"), + isSpaceRoom, }, }); }; @@ -315,7 +328,7 @@ interface IHierarchyLevelProps { hierarchy: RoomHierarchy; parents: Set; selectedMap?: Map>; - onViewRoomClick(roomId: string, autoJoin: boolean): void; + onViewRoomClick(roomId: string, autoJoin: boolean, isSpaceRoom: boolean): void; onToggleClick?(parentId: string, childId: string): void; } @@ -353,8 +366,8 @@ export const HierarchyLevel = ({ room={room} suggested={hierarchy.isSuggested(root.room_id, room.room_id)} selected={selectedMap?.get(root.room_id)?.has(room.room_id)} - onViewRoomClick={(autoJoin) => { - onViewRoomClick(room.room_id, autoJoin); + onViewRoomClick={(autoJoin, isSpaceRoom) => { + onViewRoomClick(room.room_id, autoJoin, isSpaceRoom); }} hasPermissions={hasPermissions} onToggleClick={onToggleClick ? () => onToggleClick(root.room_id, room.room_id) : undefined} @@ -373,8 +386,8 @@ export const HierarchyLevel = ({ }).length} suggested={hierarchy.isSuggested(root.room_id, space.room_id)} selected={selectedMap?.get(root.room_id)?.has(space.room_id)} - onViewRoomClick={(autoJoin) => { - onViewRoomClick(space.room_id, autoJoin); + onViewRoomClick={(autoJoin, isSpaceRoom) => { + onViewRoomClick(space.room_id, autoJoin, isSpaceRoom); }} hasPermissions={hasPermissions} onToggleClick={onToggleClick ? () => onToggleClick(root.room_id, space.room_id) : undefined} @@ -652,8 +665,8 @@ const SpaceHierarchy = ({ parents={new Set()} selectedMap={selected} onToggleClick={hasPermissions ? onToggleClick : undefined} - onViewRoomClick={(roomId, autoJoin) => { - showRoom(cli, hierarchy, roomId, autoJoin); + onViewRoomClick={(roomId, autoJoin, isSpaceRoom) => { + showRoom(cli, hierarchy, roomId, autoJoin, isSpaceRoom); }} /> ; diff --git a/src/components/views/rooms/RoomPreviewBar.tsx b/src/components/views/rooms/RoomPreviewBar.tsx index 2ebf28f90d..9d6ee56a9d 100644 --- a/src/components/views/rooms/RoomPreviewBar.tsx +++ b/src/components/views/rooms/RoomPreviewBar.tsx @@ -323,7 +323,7 @@ export default class RoomPreviewBar extends React.Component { const messageCase = this.getMessageCase(); switch (messageCase) { case MessageCase.Joining: { - title = _t("Joining room …"); + title = this.props.oobData.isSpaceRoom ? _t("Joining space …") : _t("Joining room …"); showSpinner = true; break; } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 70834c486b..28d0b2914b 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1660,6 +1660,7 @@ "%(count)s results|other": "%(count)s results", "%(count)s results|one": "%(count)s result", "This room": "This room", + "Joining space …": "Joining space …", "Joining room …": "Joining room …", "Loading …": "Loading …", "Rejecting invite …": "Rejecting invite …", diff --git a/src/stores/ThreepidInviteStore.ts b/src/stores/ThreepidInviteStore.ts index 82aa459b2f..980aa56c2b 100644 --- a/src/stores/ThreepidInviteStore.ts +++ b/src/stores/ThreepidInviteStore.ts @@ -55,6 +55,7 @@ export interface IOOBData { inviterName?: string; // The display name of the person who invited us to the room // eslint-disable-next-line camelcase room_name?: string; // The name of the room, to be used until we are told better by the server + isSpaceRoom?: boolean; // Whether or not we think the room is actually a space } const STORAGE_PREFIX = "mx_threepid_invite_";