feat(settings): General-first layout + lightbox video playback toggles

Reorder the Settings sections so General is the top and default section instead
of AI Workspace. Add two persisted settings under a new "Video playback" group:
- Autoplay in lightbox (default on)
- Start muted (default off)

VideoPlayer reads these when a video opens — autoplaying only when enabled and
starting muted when enabled, otherwise falling back to the session's last-used
mute state. Settings apply to the next opened video, not the current one.
This commit is contained in:
2026-06-21 14:39:41 +01:00
parent 3db95a4489
commit 5870205047
3 changed files with 72 additions and 7 deletions
+24
View File
@@ -12,6 +12,8 @@ import { notifyTaskComplete } from "./notifications";
const notificationTimers = new Map<string, ReturnType<typeof setTimeout>>();
const NOTIFICATION_DEBOUNCE_MS = 6000;
const THEME_KEY = "phokus-theme";
const LIGHTBOX_AUTOPLAY_KEY = "phokus.lightboxAutoplay";
const LIGHTBOX_AUTO_MUTE_KEY = "phokus.lightboxAutoMute";
export interface Folder {
id: number;
@@ -346,6 +348,8 @@ interface GalleryState {
mutedFolderIds: number[];
notificationsPaused: boolean;
theme: AppTheme;
lightboxAutoplay: boolean;
lightboxAutoMute: boolean;
// Per-folder background-worker pause flags, shared by the BackgroundTasks
// bar and the sidebar folder context menu.
workerPaused: Record<number, Record<WorkerKey, boolean>>;
@@ -445,6 +449,8 @@ interface GalleryState {
loadNotificationsPaused: () => Promise<void>;
setNotificationsPaused: (paused: boolean) => void;
setTheme: (theme: AppTheme) => void;
setLightboxAutoplay: (enabled: boolean) => void;
setLightboxAutoMute: (enabled: boolean) => void;
loadWorkerStates: () => Promise<void>;
setWorkerPaused: (folderId: number, worker: WorkerKey, paused: boolean) => void;
setAllWorkersPaused: (folderId: number, paused: boolean) => void;
@@ -515,6 +521,12 @@ function initialAiCaptionsEnabled(): boolean {
return window.localStorage.getItem(AI_CAPTIONS_ENABLED_KEY) === "true";
}
function initialBoolSetting(key: string, fallback: boolean): boolean {
if (typeof window === "undefined") return fallback;
const stored = window.localStorage.getItem(key);
return stored === null ? fallback : stored === "true";
}
function initialTheme(): AppTheme {
if (typeof window === "undefined") return "phokus";
const saved = window.localStorage.getItem(THEME_KEY);
@@ -765,6 +777,8 @@ export const useGalleryStore = create<GalleryState>((set, get) => ({
mutedFolderIds: [],
notificationsPaused: false,
theme: initialTheme(),
lightboxAutoplay: initialBoolSetting(LIGHTBOX_AUTOPLAY_KEY, true),
lightboxAutoMute: initialBoolSetting(LIGHTBOX_AUTO_MUTE_KEY, false),
workerPaused: {},
appVersion: null,
@@ -1649,6 +1663,16 @@ export const useGalleryStore = create<GalleryState>((set, get) => ({
set({ theme });
},
setLightboxAutoplay: (enabled) => {
window.localStorage.setItem(LIGHTBOX_AUTOPLAY_KEY, String(enabled));
set({ lightboxAutoplay: enabled });
},
setLightboxAutoMute: (enabled) => {
window.localStorage.setItem(LIGHTBOX_AUTO_MUTE_KEY, String(enabled));
set({ lightboxAutoMute: enabled });
},
loadWorkerStates: async () => {
const folderIds = get().folders.map((folder) => folder.id);
if (folderIds.length === 0) {