fix: add safety checks for updateAppIcon IPC calls to prevent early startup race conditions

This commit is contained in:
nvrl committed 2026-02-21 04:44:10 +01:00
1 parent fc19f66ace
commit 776e05fb52
3 files changed
+43 -6

No files matched your search

+14 -5
View File
@@ -32,15 +32,24 @@ export const AppThemeProvider: React.FC<{ children: React.ReactNode }> = ({ chil
await api.updateServerConfig({ theme });
}
if (api?.updateAppIcon) {
await api.updateAppIcon(theme);
try {
await api.updateAppIcon(theme);
} catch (e) { }
}
};
useEffect(() => {
const api = (window as any).electronAPI;
if (api?.updateAppIcon && currentTheme) {
api.updateAppIcon(currentTheme);
}
const updateIcon = async () => {
const api = (window as any).electronAPI;
if (api?.updateAppIcon && currentTheme) {
try {
await api.updateAppIcon(currentTheme);
} catch (e) {
console.warn("[ThemeContext] updateAppIcon failed (likely not registered yet)");
}
}
};
updateIcon();
}, [currentTheme]);
const theme = useMemo(() => getTheme(currentTheme), [currentTheme]);