Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Go to space landing page when clicking on a selected space #6442

Merged
merged 15 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/components/views/spaces/SpacePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import classNames from "classnames";
import { Room } from "matrix-js-sdk/src/models/room";

import { _t } from "../../../languageHandler";
import dis from "../../../dispatcher/dispatcher";
import RoomAvatar from "../avatars/RoomAvatar";
import { useContextMenu } from "../../structures/ContextMenu";
import SpaceCreateMenu from "./SpaceCreateMenu";
Expand Down Expand Up @@ -140,10 +141,14 @@ const InnerSpacePanel = React.memo<IInnerSpacePanelProps>(({ children, isPanelCo
const homeNotificationState = SpaceStore.spacesTweakAllRoomsEnabled
? RoomNotificationStateStore.instance.globalState : SpaceStore.instance.getNotificationState(HOME_SPACE);

const onHomeClick = activeSpace ?
() => SpaceStore.instance.setActiveSpace(null) :
() => dis.dispatch({ action: "view_home_page" });

return <div className="mx_SpaceTreeLevel">
<SpaceButton
className="mx_SpaceButton_home"
onClick={() => SpaceStore.instance.setActiveSpace(null)}
onClick={onHomeClick}
selected={!activeSpace}
tooltip={SpaceStore.spacesTweakAllRoomsEnabled ? _t("All rooms") : _t("Home")}
notificationState={homeNotificationState}
Expand Down
10 changes: 9 additions & 1 deletion src/components/views/spaces/SpaceTreeLevel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,15 @@ export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
private onClick = (ev: React.MouseEvent) => {
ev.preventDefault();
ev.stopPropagation();
SpaceStore.instance.setActiveSpace(this.props.space);

if (this.props.activeSpaces.includes(this.props.space)) {
defaultDispatcher.dispatch({
action: "view_room",
room_id: this.props.space.roomId,
});
} else {
SpaceStore.instance.setActiveSpace(this.props.space);
}
};

private onMenuOpenClick = (ev: React.MouseEvent) => {
Expand Down