Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
sync theme change across screens
David Anyatonwu1b1d9c579c3b
diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsxindex 75ccef64e..54bee2470 100644--- a/apps/desktop/src/App.tsx+++ b/apps/desktop/src/App.tsx@@ -22,6 +22,8 @@ const queryClient = new QueryClient({});export default function App() {+ const darkMode = themeStore.isDarkMode;+onMount(async () => {await themeStore.initialize();@@ -37,36 +39,38 @@ export default function App() {});return (- <ErrorBoundary- fallback={(e: Error) => {- console.error(e);- return (- <>- <p>{e.toString()}</p>- <p>{e.stack?.toString()}</p>- </>- );- }}- >- <QueryClientProvider client={queryClient}>- <Router- root={(props) => {- const matches = useCurrentMatches();+ <div class={darkMode() ? "dark" : ""}>+ <ErrorBoundary+ fallback={(e: Error) => {+ console.error(e);+ return (+ <>+ <p>{e.toString()}</p>+ <p>{e.stack?.toString()}</p>+ </>+ );+ }}+ >+ <QueryClientProvider client={queryClient}>+ <Router+ root={(props) => {+ const matches = useCurrentMatches();- onMount(() => {- for (const match of matches()) {- if (match.route.info?.AUTO_SHOW_WINDOW === false) return;- }+ onMount(() => {+ for (const match of matches()) {+ if (match.route.info?.AUTO_SHOW_WINDOW === false) return;+ }- getCurrentWindow().show();- });+ getCurrentWindow().show();+ });- return <Suspense>{props.children}</Suspense>;- }}- >- <FileRoutes />- </Router>- </QueryClientProvider>- </ErrorBoundary>+ return <Suspense>{props.children}</Suspense>;+ }}+ >+ <FileRoutes />+ </Router>+ </QueryClientProvider>+ </ErrorBoundary>+ </div>);}diff --git a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx b/apps/desktop/src/routes/(window-chrome)/settings/general.tsxindex 6c135a494..f2081b3c5 100644--- a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx@@ -113,8 +113,12 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {}}- if (settingsList.find((setting) => setting.key === key)?.onChange) {- await settingsList.find((setting) => setting.key === key)?.onChange(value);+ // Find the setting once and store it+ const setting = settingsList.find((s) => s.key === key);++ // If setting exists and has onChange handler, call it+ if (setting?.onChange) {+ await setting.onChange(value);}setSettings(key as keyof GeneralSettingsStore, value);diff --git a/apps/desktop/src/store/theme.ts b/apps/desktop/src/store/theme.tsindex 1d9bf97df..79a89512f 100644--- a/apps/desktop/src/store/theme.ts+++ b/apps/desktop/src/store/theme.ts@@ -1,16 +1,24 @@import { createSignal } from "solid-js";import { generalSettingsStore } from "~/store";import type { GeneralSettingsStore } from "~/utils/tauri";+import { emit, listen } from "@tauri-apps/api/event";+const THEME_CHANGE_EVENT = "theme-change";const [isDarkMode, setIsDarkMode] = createSignal(false);+const applyTheme = (darkMode: boolean) => {+ setIsDarkMode(darkMode);+ document.documentElement.classList.toggle("dark", darkMode);+};+export const themeStore = {isDarkMode,toggleTheme: async () => {const newValue = !isDarkMode();- setIsDarkMode(newValue);- document.documentElement.classList.toggle("dark", newValue);+ applyTheme(newValue);await generalSettingsStore.set({ darkMode: newValue } as Partial<GeneralSettingsStore>);+ // Emit theme change event to other windows+ await emit(THEME_CHANGE_EVENT, { darkMode: newValue });},initialize: async () => {const settings = await generalSettingsStore.get();@@ -19,16 +27,20 @@ export const themeStore = {const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;const darkMode = settings?.darkMode ?? prefersDark;- setIsDarkMode(darkMode);- document.documentElement.classList.toggle("dark", darkMode);+ applyTheme(darkMode);++ // Listen for theme changes from other windows+ await listen(THEME_CHANGE_EVENT, (event: any) => {+ applyTheme(event.payload.darkMode);+ });// Listen for system theme changeswindow.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", (e) => {// Only change theme if user hasn't explicitly set a preferenceif (settings?.darkMode === undefined) {- setIsDarkMode(e.matches);- document.documentElement.classList.toggle("dark", e.matches);+ applyTheme(e.matches);+ emit(THEME_CHANGE_EVENT, { darkMode: e.matches });}});},diff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.tsindex bff1f0e77..22f313fa6 100644--- a/packages/ui-solid/src/auto-imports.d.ts+++ b/packages/ui-solid/src/auto-imports.d.ts@@ -6,67 +6,27 @@// biome-ignore lint: disableexport {}declare global {- const IconCapApps: typeof import('~icons/cap/apps.jsx')['default']- const IconCapArrows: typeof import('~icons/cap/arrows.jsx')['default']- const IconCapAudioOn: typeof import('~icons/cap/audio-on.jsx')['default']- const IconCapBlur: typeof import('~icons/cap/blur.jsx')['default']const IconCapCamera: typeof import('~icons/cap/camera.jsx')['default']const IconCapChevronDown: typeof import('~icons/cap/chevron-down.jsx')['default']const IconCapCircleCheck: typeof import('~icons/cap/circle-check.jsx')['default']- const IconCapCirclePlus: typeof import('~icons/cap/circle-plus.jsx')['default']const IconCapCircleX: typeof import('~icons/cap/circle-x.jsx')['default']const IconCapCopy: typeof import('~icons/cap/copy.jsx')['default']- const IconCapCorners: typeof import('~icons/cap/corners.jsx')['default']- const IconCapCrop: typeof import('~icons/cap/crop.jsx')['default']- const IconCapCursor: typeof import('~icons/cap/cursor.jsx')['default']const IconCapEditor: typeof import('~icons/cap/editor.jsx')['default']- const IconCapEnlarge: typeof import('~icons/cap/enlarge.jsx')['default']- const IconCapFrameFirst: typeof import('~icons/cap/frame-first.jsx')['default']- const IconCapFrameLast: typeof import('~icons/cap/frame-last.jsx')['default']const IconCapHotkeys: typeof import('~icons/cap/hotkeys.jsx')['default']- const IconCapImage: typeof import('~icons/cap/image.jsx')['default']- const IconCapInset: typeof import('~icons/cap/inset.jsx')['default']- const IconCapLayout: typeof import('~icons/cap/layout.jsx')['default']const IconCapLogo: typeof import('~icons/cap/logo.jsx')['default']const IconCapLogoFull: typeof import('~icons/cap/logo-full.jsx')['default']- const IconCapMessageBubble: typeof import('~icons/cap/message-bubble.jsx')['default']const IconCapMicrophone: typeof import('~icons/cap/microphone.jsx')['default']- const IconCapMoreVertical: typeof import('~icons/cap/more-vertical.jsx')['default']- const IconCapPadding: typeof import('~icons/cap/padding.jsx')['default']- const IconCapPauseCircle: typeof import('~icons/cap/pause-circle.jsx')['default']- const IconCapPlayCircle: typeof import('~icons/cap/play-circle.jsx')['default']- const IconCapPresets: typeof import('~icons/cap/presets.jsx')['default']- const IconCapRedo: typeof import('~icons/cap/redo.jsx')['default']- const IconCapRestart: typeof import('~icons/cap/restart.jsx')['default']- const IconCapScissors: typeof import('~icons/cap/scissors.jsx')['default']const IconCapSettings: typeof import('~icons/cap/settings.jsx')['default']- const IconCapShadow: typeof import('~icons/cap/shadow.jsx')['default']- const IconCapSquare: typeof import('~icons/cap/square.jsx')['default']- const IconCapStopCircle: typeof import('~icons/cap/stop-circle.jsx')['default']- const IconCapTrash: typeof import('~icons/cap/trash.jsx')['default']- const IconCapUndo: typeof import('~icons/cap/undo.jsx')['default']const IconCapUpload: typeof import('~icons/cap/upload.jsx')['default']const IconLucideBell: typeof import('~icons/lucide/bell.jsx')['default']- const IconLucideBlocks: typeof import('~icons/lucide/blocks.jsx')['default']- const IconLucideBrickWall: typeof import('~icons/lucide/brick-wall.jsx')['default']- const IconLucideCable: typeof import('~icons/lucide/cable.jsx')['default']const IconLucideCamera: typeof import('~icons/lucide/camera.jsx')['default']const IconLucideCheck: typeof import('~icons/lucide/check.jsx')['default']- const IconLucideCloud: typeof import('~icons/lucide/cloud.jsx')['default']const IconLucideDatabase: typeof import('~icons/lucide/database.jsx')['default']- const IconLucideDevice: typeof import('~icons/lucide/device.jsx')['default']const IconLucideEdit: typeof import('~icons/lucide/edit.jsx')['default']const IconLucideEye: typeof import('~icons/lucide/eye.jsx')['default']const IconLucideFolder: typeof import('~icons/lucide/folder.jsx')['default']const IconLucideLayoutGrid: typeof import('~icons/lucide/layout-grid.jsx')['default']const IconLucideLoaderCircle: typeof import('~icons/lucide/loader-circle.jsx')['default']const IconLucideMessageSquarePlus: typeof import('~icons/lucide/message-square-plus.jsx')['default']- const IconLucidePlugZap: typeof import('~icons/lucide/plug-zap.jsx')['default']- const IconLucideRabbit: typeof import('~icons/lucide/rabbit.jsx')['default']- const IconLucideRotateCcw: typeof import('~icons/lucide/rotate-ccw.jsx')['default']- const IconLucideSearch: typeof import('~icons/lucide/search.jsx')['default']- const IconLucideSettings: typeof import('~icons/lucide/settings.jsx')['default']const IconLucideSquarePlay: typeof import('~icons/lucide/square-play.jsx')['default']- const IconLucideVolume2: typeof import('~icons/lucide/volume2.jsx')['default']- const IconLucideVolumeX: typeof import('~icons/lucide/volume-x.jsx')['default']}