new day, new theme check

Signed-off-by: FTCHD <144691102+FTCHD@users.noreply.github.com>
This commit is contained in:
FTCHD
2025-10-28 19:16:42 +01:00
parent 84cc298cfa
commit 55151b15b7
2 changed files with 55 additions and 26 deletions
+6 -2
View File
@@ -112,7 +112,9 @@ interface PersistedState {
hideStartup: boolean
theme: 'light' | 'dark' | undefined
theme: {
tray: 'light' | 'dark' | undefined
}
}
const getStorage = (store: LazyStore): StateStorage => ({
@@ -256,7 +258,9 @@ export const usePersistedStore = create<PersistedState>()(
hideStartup: false,
theme: undefined,
theme: {
tray: undefined,
},
}),
{
name: 'store',
+49 -24
View File
@@ -25,41 +25,66 @@ async function getTray() {
}
async function resolveTrayIconForTheme() {
// const existingTheme = usePersistedStore.getState().theme
// if (existingTheme) {
// return existingTheme === 'dark' ? 'icons/favicon/icon.png' : 'icons/favicon/icon-light.png'
// }
const existingTheme = usePersistedStore.getState().theme
if (typeof existingTheme === 'string') {
usePersistedStore.setState({ theme: { tray: undefined } })
}
if (existingTheme.tray) {
return existingTheme.tray === 'dark'
? 'icons/favicon/icon.png'
: 'icons/favicon/icon-light.png'
}
let theme: 'light' | 'dark' = 'dark'
try {
const detectedTheme = (await invoke<string>('get_system_theme')) as
| 'light'
| 'dark'
| 'unknown'
if (detectedTheme === 'unknown') {
const answer = await ask(
'Could not determine your system theme, please select the correct one below',
{
title: 'Hmm...',
okLabel: 'Dark',
cancelLabel: 'Light',
if (['macos', 'windows'].includes(platform())) {
try {
const detectedTheme = (await invoke<string>('get_system_theme')) as
| 'light'
| 'dark'
| 'unknown'
if (detectedTheme === 'unknown') {
const answer = await ask(
'Could not determine your system theme, please select the correct one below',
{
title: 'Hmm...',
okLabel: 'Dark',
cancelLabel: 'Light',
}
)
if (answer) {
theme = 'dark'
} else {
theme = 'light'
}
)
if (answer) {
theme = 'dark'
} else {
theme = 'light'
theme = detectedTheme
}
} catch {}
} else {
const answer = await ask(
'Based on your tray/menubar, how do you want the icon to look?\n\nIf your menubar has a dark background select light, otherwise select dark.',
{
title: 'Greetings, Linux User',
okLabel: 'Dark',
cancelLabel: 'Light',
}
)
if (answer) {
theme = 'dark'
} else {
theme = detectedTheme
theme = 'light'
}
} catch {}
}
console.log('[resolveTrayIconForTheme] theme', theme)
usePersistedStore.setState({ theme: undefined })
usePersistedStore.setState({ theme: { tray: theme } })
const pickedPath = theme === 'dark' ? 'icons/favicon/icon.png' : 'icons/favicon/icon-light.png'
console.log('[resolveTrayIconForTheme] pickedPath', pickedPath)