diff --git a/instance/src/web/src/pages/app/Navigation.tsx b/instance/src/web/src/pages/app/Navigation.tsx index edac012..61e5e91 100644 --- a/instance/src/web/src/pages/app/Navigation.tsx +++ b/instance/src/web/src/pages/app/Navigation.tsx @@ -1,8 +1,8 @@ import UKNavigationRail from "@onlineworkspace/uikit-solid/src/components/navigationRail/UKNavigationRail.jsx"; import UKText from "@onlineworkspace/uikit-solid/src/components/text/UKText.jsx"; import useIsMobile from "@onlineworkspace/uikit-solid/src/core/useIsMobile.js"; -import { useLocation, useNavigate } from "@solidjs/router"; -import { type Component, createResource, createSignal, type ParentProps, Show } from "solid-js"; +import {useLocation, useNavigate} from "@solidjs/router"; +import {type Component, createMemo, createResource, createSignal, type ParentProps, Show} from "solid-js"; import trpc from "../../lib/trpc"; import NavigationRailApplications from "./components/NavigationRail/components/navigationRailApplications/NavigationRailApplications"; import NavigationRailAvatar from "./components/NavigationRail/components/navigationRailAvatar/NavigationRailAvatar"; @@ -15,41 +15,45 @@ const AppNavigation: Component = (props) => { const navigate = useNavigate(); const isMobile = useIsMobile(); - const [quickShortcuts] = createResource(() => trpc.app.navigation.getQuickShortcuts.query(), { initialValue: [] }); - const [expanded, setExpanded] = createSignal(false); - const [toggledDrawer, setToggledDrawer] = createSignal<"applications" | "notifications" | false>(false); + const [ quickShortcuts ] = createResource(() => trpc.app.navigation.getQuickShortcuts.query(), {initialValue: []}); + const [ expanded, setExpanded ] = createSignal(false); + const [ toggledDrawer, setToggledDrawer ] = createSignal<"applications" | "notifications" | false>(false); + + const memoedNavigationItems = createMemo(() => { + return quickShortcuts() + .map((sc) => { + return { + icon: sc.icon || { + type: "icon", + value: "indeterminate_question_box", + }, + label: sc.label, + active: location.pathname.startsWith(sc.location.value), + onClick() { + if (sc.location.type === "local") { + navigate(sc.location.value); + } else if (sc.location.type === "remote") { + window.location.href = sc.location.value; + } + }, + onMiddleClick() { + if (sc.location.type === "local") { + window.open(sc.location.value, "_blank"); + } else if (sc.location.type === "remote") { + window.open(sc.location.value, "_blank"); + } + }, + }; + }) + .slice(0, isMobile() ? 3 : undefined) + }) return ( { - return { - icon: sc.icon || { - type: "icon", - value: "indeterminate_question_box", - }, - label: sc.label, - active: location.pathname.startsWith(sc.location.value), - onClick() { - if (sc.location.type === "local") { - navigate(sc.location.value); - } else if (sc.location.type === "remote") { - window.location.href = sc.location.value; - } - }, - onMiddleClick() { - if (sc.location.type === "local") { - window.open(sc.location.value, "_blank"); - } else if (sc.location.type === "remote") { - window.open(sc.location.value, "_blank"); - } - }, - }; - }) - .slice(0, isMobile() ? 3 : undefined)} - setExpanded={!isMobile() ? (expandedState) => setExpanded(expandedState) : undefined} + expanded={isMobile() ? false : expanded()} + items={memoedNavigationItems()} + setExpanded={isMobile() ? undefined : (expandedState) => setExpanded(expandedState)} anchorPoints={{ topMost: ( <>