fix: add safety checks for updateAppIcon IPC calls to prevent early startup race conditions
This commit is contained in:
@@ -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]);
|
||||
|
||||
Reference in New Issue
Block a user