diff --git a/src/components/structures/UserMenuButton.tsx b/src/components/structures/UserMenuButton.tsx index 41b2c3ab60..f3626ba270 100644 --- a/src/components/structures/UserMenuButton.tsx +++ b/src/components/structures/UserMenuButton.tsx @@ -32,6 +32,8 @@ import SettingsStore, {SettingLevel} from "../../settings/SettingsStore"; import {getCustomTheme} from "../../theme"; import {getHostingLink} from "../../utils/HostingLink"; import AccessibleButton, {ButtonEvent} from "../views/elements/AccessibleButton"; +import SdkConfig from "../../SdkConfig"; +import {getHomePageUrl} from "../../utils/pages"; interface IProps { } @@ -67,6 +69,10 @@ export default class UserMenuButton extends React.Component { } } + private get hasHomePage(): boolean { + return !!getHomePageUrl(SdkConfig.get()); + } + public componentDidMount() { this.dispatcherRef = defaultDispatcher.register(this.onAction); this.themeWatcherRef = SettingsStore.watchSetting("theme", null, this.onThemeChanged); @@ -147,6 +153,13 @@ export default class UserMenuButton extends React.Component { this.setState({menuDisplayed: false}); // also close the menu }; + private onHomeClick = (ev: ButtonEvent) => { + ev.preventDefault(); + ev.stopPropagation(); + + defaultDispatcher.dispatch({action: 'view_home_page'}); + }; + public render() { let contextMenu; if (this.state.menuDisplayed) { @@ -172,6 +185,18 @@ export default class UserMenuButton extends React.Component { ); } + let homeButton = null; + if (this.hasHomePage) { + homeButton = ( +
  • + + + {_t("Home")} + +
  • + ); + } + const elementRect = this.buttonRef.current.getBoundingClientRect(); contextMenu = ( { {hostingLink}
      + {homeButton}
    • this.onSettingsOpen(e, USER_NOTIFICATIONS_TAB)}>