export async function syncThemeWithLocal() {
try {
const { local, system } = await getCurrentTheme();
// If we have a stored preference, use it
if (local) {
await setTheme(local);
return;
}
// Otherwise set system as default and save it to local storage
// This ensures we have a saved preference for next time
await setTheme(system || "light");
} catch (error) {
console.error("Failed to sync theme:", error);
// Fallback to light theme if there's an error
await setTheme("light");
}
}
Syncs application theme with stored preference or system preference. Falls back to light theme if sync fails.