Don't keep spinning if joining space child failed (#7129)
This commit is contained in:
parent
894ae6ab88
commit
a057ec18ca
2 changed files with 15 additions and 12 deletions
|
@ -68,7 +68,6 @@ interface IProps {
|
||||||
initialText?: string;
|
initialText?: string;
|
||||||
additionalButtons?: ReactNode;
|
additionalButtons?: ReactNode;
|
||||||
showRoom(cli: MatrixClient, hierarchy: RoomHierarchy, roomId: string, roomType?: RoomType): void;
|
showRoom(cli: MatrixClient, hierarchy: RoomHierarchy, roomId: string, roomType?: RoomType): void;
|
||||||
joinRoom(cli: MatrixClient, hierarchy: RoomHierarchy, roomId: string): void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ITileProps {
|
interface ITileProps {
|
||||||
|
@ -78,7 +77,7 @@ interface ITileProps {
|
||||||
numChildRooms?: number;
|
numChildRooms?: number;
|
||||||
hasPermissions?: boolean;
|
hasPermissions?: boolean;
|
||||||
onViewRoomClick(): void;
|
onViewRoomClick(): void;
|
||||||
onJoinRoomClick(): void;
|
onJoinRoomClick(): Promise<unknown>;
|
||||||
onToggleClick?(): void;
|
onToggleClick?(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,9 +114,9 @@ const Tile: React.FC<ITileProps> = ({
|
||||||
setBusy(true);
|
setBusy(true);
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
onJoinRoomClick();
|
onJoinRoomClick().then(() => awaitRoomDownSync(cli, room.room_id)).then(setJoinedRoom).finally(() => {
|
||||||
setJoinedRoom(await awaitRoomDownSync(cli, room.room_id));
|
setBusy(false);
|
||||||
setBusy(false);
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
let button;
|
let button;
|
||||||
|
@ -141,7 +140,7 @@ const Tile: React.FC<ITileProps> = ({
|
||||||
>
|
>
|
||||||
{ _t("View") }
|
{ _t("View") }
|
||||||
</AccessibleButton>;
|
</AccessibleButton>;
|
||||||
} else if (onJoinClick) {
|
} else {
|
||||||
button = <AccessibleButton
|
button = <AccessibleButton
|
||||||
onClick={onJoinClick}
|
onClick={onJoinClick}
|
||||||
kind="primary"
|
kind="primary"
|
||||||
|
@ -343,7 +342,7 @@ export const showRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: st
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const joinRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: string): void => {
|
export const joinRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: string): Promise<unknown> => {
|
||||||
// Don't let the user view a room they won't be able to either peek or join:
|
// Don't let the user view a room they won't be able to either peek or join:
|
||||||
// fail earlier so they don't have to click back to the directory.
|
// fail earlier so they don't have to click back to the directory.
|
||||||
if (cli.isGuest()) {
|
if (cli.isGuest()) {
|
||||||
|
@ -351,11 +350,15 @@ export const joinRoom = (cli: MatrixClient, hierarchy: RoomHierarchy, roomId: st
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cli.joinRoom(roomId, {
|
const prom = cli.joinRoom(roomId, {
|
||||||
viaServers: Array.from(hierarchy.viaMap.get(roomId) || []),
|
viaServers: Array.from(hierarchy.viaMap.get(roomId) || []),
|
||||||
}).catch(err => {
|
});
|
||||||
|
|
||||||
|
prom.catch(err => {
|
||||||
RoomViewStore.showJoinRoomError(err, roomId);
|
RoomViewStore.showJoinRoomError(err, roomId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return prom;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface IHierarchyLevelProps {
|
interface IHierarchyLevelProps {
|
||||||
|
@ -365,7 +368,7 @@ interface IHierarchyLevelProps {
|
||||||
parents: Set<string>;
|
parents: Set<string>;
|
||||||
selectedMap?: Map<string, Set<string>>;
|
selectedMap?: Map<string, Set<string>>;
|
||||||
onViewRoomClick(roomId: string, roomType?: RoomType): void;
|
onViewRoomClick(roomId: string, roomType?: RoomType): void;
|
||||||
onJoinRoomClick(roomId: string): void;
|
onJoinRoomClick(roomId: string): Promise<unknown>;
|
||||||
onToggleClick?(parentId: string, childId: string): void;
|
onToggleClick?(parentId: string, childId: string): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ import {
|
||||||
showSpaceInvite,
|
showSpaceInvite,
|
||||||
showSpaceSettings,
|
showSpaceSettings,
|
||||||
} from "../../utils/space";
|
} from "../../utils/space";
|
||||||
import SpaceHierarchy, { joinRoom, showRoom } from "./SpaceHierarchy";
|
import SpaceHierarchy, { showRoom } from "./SpaceHierarchy";
|
||||||
import MemberAvatar from "../views/avatars/MemberAvatar";
|
import MemberAvatar from "../views/avatars/MemberAvatar";
|
||||||
import SpaceStore from "../../stores/spaces/SpaceStore";
|
import SpaceStore from "../../stores/spaces/SpaceStore";
|
||||||
import FacePile from "../views/elements/FacePile";
|
import FacePile from "../views/elements/FacePile";
|
||||||
|
@ -508,7 +508,7 @@ const SpaceLanding = ({ space }: { space: Room }) => {
|
||||||
) }
|
) }
|
||||||
</RoomTopic>
|
</RoomTopic>
|
||||||
|
|
||||||
<SpaceHierarchy space={space} showRoom={showRoom} joinRoom={joinRoom} additionalButtons={addRoomButton} />
|
<SpaceHierarchy space={space} showRoom={showRoom} additionalButtons={addRoomButton} />
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue