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

This commit is contained in:
2026-02-21 04:44:10 +01:00
parent fc19f66ace
commit 776e05fb52
3 changed files with 43 additions and 6 deletions

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]);