You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-07 10:46:24 +03:00
Say Joining space instead of Joining room where we know its a space
This commit is contained in:
@@ -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<ITileProps> = ({
|
||||
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<ITileProps> = ({
|
||||
</li>;
|
||||
};
|
||||
|
||||
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<string>;
|
||||
selectedMap?: Map<string, Set<string>>;
|
||||
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);
|
||||
}}
|
||||
/>
|
||||
</>;
|
||||
|
||||
Reference in New Issue
Block a user