Feat: add persisted account theme settings
This commit is contained in:
@@ -1,14 +1,8 @@
|
||||
// Path: Frontend/src/components/app-shell/data/app-shell.context.tsx
|
||||
|
||||
import {
|
||||
createContext,
|
||||
createMemo,
|
||||
createSignal,
|
||||
onMount,
|
||||
useContext,
|
||||
type JSX,
|
||||
} from "solid-js";
|
||||
import { createContext, createMemo, createSignal, onMount, useContext, type JSX } from "solid-js";
|
||||
import { resolveAPIBase } from "../../../lib/api";
|
||||
import { applyThemePresetById, resolvePreferredThemePresetId } from "../../../helper/themeRuntime";
|
||||
import {
|
||||
buildActiveDepartment,
|
||||
buildActiveProject,
|
||||
@@ -56,7 +50,13 @@ export const AppShellDataProvider = (props: { children: JSX.Element }): JSX.Elem
|
||||
throw new Error(errorMessage || "Failed to load app shell state.");
|
||||
}
|
||||
|
||||
setPayload(normalizeAppShellPayload(body.data));
|
||||
const normalizedPayload = normalizeAppShellPayload(body.data);
|
||||
const persistedThemePresetId = normalizedPayload.admin?.themePresetId?.trim();
|
||||
if (persistedThemePresetId && persistedThemePresetId !== resolvePreferredThemePresetId()) {
|
||||
await applyThemePresetById(persistedThemePresetId);
|
||||
}
|
||||
|
||||
setPayload(normalizedPayload);
|
||||
setStatus("success");
|
||||
} catch (loadError) {
|
||||
setStatus("error");
|
||||
@@ -72,6 +72,7 @@ export const AppShellDataProvider = (props: { children: JSX.Element }): JSX.Elem
|
||||
status,
|
||||
error,
|
||||
installation: createMemo(() => payload()?.installation),
|
||||
admin: createMemo(() => payload()?.admin),
|
||||
railItems: createMemo(() => buildRailItems(payload())),
|
||||
activeServer: createMemo(() => buildActiveServer(payload())),
|
||||
activeProject: createMemo(() => buildActiveProject(payload())),
|
||||
|
||||
@@ -30,6 +30,7 @@ export type AppShellAdmin = {
|
||||
displayName: string;
|
||||
isInstanceAdmin: boolean;
|
||||
homeTitle: string;
|
||||
themePresetId?: string;
|
||||
};
|
||||
|
||||
export type AppShellOrganization = {
|
||||
@@ -87,6 +88,7 @@ export type AppShellContextValue = {
|
||||
status: Accessor<"idle" | "loading" | "success" | "error">;
|
||||
error: Accessor<string>;
|
||||
installation: Accessor<AppShellInstallation | undefined>;
|
||||
admin: Accessor<AppShellAdmin | undefined>;
|
||||
railItems: Accessor<readonly RailItem[]>;
|
||||
activeServer: Accessor<ActiveServer>;
|
||||
activeProject: Accessor<ActiveProject>;
|
||||
|
||||
Reference in New Issue
Block a user