diff --git a/frontend/dist-electron/main.js b/frontend/dist-electron/main.js index 4b529a1..2217aba 100644 --- a/frontend/dist-electron/main.js +++ b/frontend/dist-electron/main.js @@ -99,7 +99,14 @@ const createTray = () => { mainWindow.show(); mainWindow.focus(); } }); - updateTrayMenu(); + // Load initial themed icon + const config = store.get('serverConfig'); + if (config?.theme) { + setAppIcon(config.theme); + } + else { + updateTrayMenu(); // Fallback to refresh menu + } } catch (e) { } }; @@ -127,6 +134,21 @@ const updateTrayMenu = () => { ]); tray.setContextMenu(contextMenu); }; +const setAppIcon = (themeName = 'steam') => { + const assetsDir = path_1.default.join(__dirname, '..', 'assets-build', 'icons'); + const iconPath = path_1.default.join(assetsDir, `${themeName}.svg`); + if (!fs_1.default.existsSync(iconPath)) + return; + const icon = electron_1.nativeImage.createFromPath(iconPath); + // Update Tray + if (tray) { + tray.setImage(icon.resize({ width: 16, height: 16 })); + } + // Update Main Window + if (mainWindow) { + mainWindow.setIcon(icon); + } +}; // --- Steam Logic --- const killSteam = async () => { return new Promise((resolve) => { @@ -588,6 +610,11 @@ electron_1.ipcMain.handle('admin-delete-user', async (event, userId) => { initBa electron_1.ipcMain.handle('admin-get-accounts', async () => { initBackend(); return backend ? await backend.getAdminAccounts() : []; }); electron_1.ipcMain.handle('admin-remove-account', async (event, steamId) => { initBackend(); if (backend) await backend.forceRemoveAccount(steamId); return true; }); +electron_1.ipcMain.handle('force-sync', async () => { await syncAccounts(true); return true; }); +electron_1.ipcMain.handle('update-app-icon', (event, themeName) => { + setAppIcon(themeName); + return true; +}); electron_1.ipcMain.handle('switch-account', async (event, loginName) => { if (!loginName) return false; diff --git a/frontend/dist-electron/preload.js b/frontend/dist-electron/preload.js index 4c648d2..b376fc2 100644 --- a/frontend/dist-electron/preload.js +++ b/frontend/dist-electron/preload.js @@ -11,6 +11,7 @@ electron_1.contextBridge.exposeInMainWorld('electronAPI', { revokeAccountAccess: (steamId, targetSteamId) => electron_1.ipcRenderer.invoke('revoke-account-access', steamId, targetSteamId), revokeAllAccountAccess: (steamId) => electron_1.ipcRenderer.invoke('revoke-all-account-access', steamId), openExternal: (url) => electron_1.ipcRenderer.invoke('open-external', url), + updateAppIcon: (theme) => electron_1.ipcRenderer.invoke('update-app-icon', theme), openSteamAppLogin: () => electron_1.ipcRenderer.invoke('open-steam-app-login'), openSteamLogin: (steamId) => electron_1.ipcRenderer.invoke('open-steam-login', steamId), // Server Config & Auth diff --git a/frontend/src/theme/ThemeContext.tsx b/frontend/src/theme/ThemeContext.tsx index 4eb94a4..6ae749d 100644 --- a/frontend/src/theme/ThemeContext.tsx +++ b/frontend/src/theme/ThemeContext.tsx @@ -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]);