diff --git a/src/renderer/components/+preferences/preferences.tsx b/src/renderer/components/+preferences/preferences.tsx index 503e398f08..d17f1de8b4 100644 --- a/src/renderer/components/+preferences/preferences.tsx +++ b/src/renderer/components/+preferences/preferences.tsx @@ -1,7 +1,7 @@ import "./preferences.scss"; import React from "react"; -import { computed, observable } from "mobx"; +import { computed, observable, reaction } from "mobx"; import { observer } from "mobx-react"; import { userStore } from "../../../common/user-store"; @@ -31,9 +31,12 @@ export class Preferences extends React.Component { } componentDidMount() { - const { hash } = navigation.location; - - document.getElementById(hash.slice(1))?.scrollIntoView(); + reaction(() => navigation.location.hash, hash => { + document.getElementById(hash.slice(1))?.scrollIntoView(); + navigation.location.hash = ""; + }, { + fireImmediately: true + }); } render() { diff --git a/src/renderer/protocol-handler/app-handlers.ts b/src/renderer/protocol-handler/app-handlers.ts index d6b34181a9..256b8b396a 100644 --- a/src/renderer/protocol-handler/app-handlers.ts +++ b/src/renderer/protocol-handler/app-handlers.ts @@ -15,11 +15,19 @@ export function bindProtocolAddRouteHandlers() { .addInternalHandler("/preferences", ({ search: { highlight }}) => { navigate(preferencesURL({ fragment: highlight })); }) + .addInternalHandler("/", () => { + navigate(landingURL()); + }) .addInternalHandler("/landing", () => { navigate(landingURL()); }) - .addInternalHandler("/", () => { - navigate(landingURL()); + .addInternalHandler("/landing/:workspaceId", ({ pathname: { workspaceId } }) => { + if (workspaceStore.getById(workspaceId)) { + workspaceStore.setActive(workspaceId); + navigate(landingURL()); + } else { + console.log("[APP-HANDLER]: workspace with given ID does not exist", { workspaceId }); + } }) .addInternalHandler("/cluster", () => { navigate(addClusterURL()); @@ -30,6 +38,8 @@ export function bindProtocolAddRouteHandlers() { if (cluster) { workspaceStore.setActive(cluster.workspace); navigate(clusterViewURL({ params: { clusterId } })); + } else { + console.log("[APP-HANDLER]: cluster with given ID does not exist", { clusterId }); } }) .addInternalHandler("/cluster/:clusterId/settings", ({ pathname: { clusterId } }) => { @@ -38,6 +48,8 @@ export function bindProtocolAddRouteHandlers() { if (cluster) { workspaceStore.setActive(cluster.workspace); navigate(clusterSettingsURL({ params: { clusterId } })); + } else { + console.log("[APP-HANDLER]: cluster with given ID does not exist", { clusterId }); } }) .addInternalHandler("/extensions", () => {