diff --git a/src/Stores.ts b/src/Stores.ts index 304b4b85..3608796b 100644 --- a/src/Stores.ts +++ b/src/Stores.ts @@ -20,8 +20,6 @@ export enum GridTypes { ICON="Icon" } -export const focusedWindow = sharedStore("main", "focusedWindow"); - export const needsSGDBAPIKey = sharedStore(true, "needsSGDBAPIKey"); export const needsSteamKey = sharedStore(true, "needsSteamKey"); diff --git a/src/lib/controllers/AppController.ts b/src/lib/controllers/AppController.ts index 9ba5bb6e..98e09328 100644 --- a/src/lib/controllers/AppController.ts +++ b/src/lib/controllers/AppController.ts @@ -206,9 +206,9 @@ export class AppController { const res = await http.fetch(`http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key=${get(steamKey)}&steamid=${bUserId}&format=json&include_appinfo=true&include_played_free_games=true`); if (res.ok) { - return Object.entries(res.data.response).map(([appid, game]: [any, any]) => { + return res.data.response.games.map((game: any) => { return { - "appid": appid, + "appid": game.appid, "name": game.name } }).sort((gameA: SteamGame, gameB: SteamGame) => gameA.name.localeCompare(gameB.name)); diff --git a/src/lib/controllers/WindowController.ts b/src/lib/controllers/WindowController.ts index 758e4cb5..3ce692f2 100644 --- a/src/lib/controllers/WindowController.ts +++ b/src/lib/controllers/WindowController.ts @@ -18,14 +18,13 @@ import { WebviewWindow } from "@tauri-apps/api/window"; import { LogController } from "./LogController"; -import { focusedWindow } from "../../Stores"; /** * Controller class for managing app windows. */ export class WindowController { - private static mainWindow = WebviewWindow.getByLabel('main'); - private static settingsWindow = WebviewWindow.getByLabel('settings'); + static mainWindow = WebviewWindow.getByLabel('main'); + static settingsWindow = WebviewWindow.getByLabel('settings'); /** * Closes the window with the provided label. @@ -47,7 +46,6 @@ export class WindowController { LogController.log("Opening settings window."); await this.settingsWindow.show(); await this.settingsWindow.setFocus(); - focusedWindow.set("settings"); } /** @@ -57,6 +55,5 @@ export class WindowController { static async closeSettingsWindow(): Promise { LogController.log("Closing settings window."); await this.settingsWindow.hide(); - focusedWindow.set("main"); } } \ No newline at end of file diff --git a/src/windows/main/Main.svelte b/src/windows/main/Main.svelte index f6348cbf..ca911b6d 100644 --- a/src/windows/main/Main.svelte +++ b/src/windows/main/Main.svelte @@ -10,11 +10,19 @@ import Grids from "../../components/core/grids/Grids.svelte"; import { AppController } from "../../lib/controllers/AppController"; import { exit } from "@tauri-apps/api/process"; - import { activeUserId, focusedWindow, isOnline } from "../../Stores"; + import { activeUserId, isOnline } from "../../Stores"; import { ToastController } from "../../lib/controllers/ToastController"; - import { appWindow } from "@tauri-apps/api/window"; + import { WindowController } from "../../lib/controllers/WindowController"; + + let mainFocusUnsub: any; + + let isFocused = false; onMount(async () => { + mainFocusUnsub = await WindowController.mainWindow.onFocusChanged(({ payload: focused }) => { + isFocused = focused; + }); + await AppController.setup(); if (navigator.onLine) { @@ -34,15 +42,15 @@ onDestroy(async () => { await AppController.destroy(); + + if (mainFocusUnsub) mainFocusUnsub(); }); - $focusedWindow = "main"} /> -
-
+
@@ -70,6 +78,8 @@ align-items: center; color: var(--font-color); + + transition: opacity 0.1s ease-in-out; } .wrap { @@ -102,6 +112,6 @@ } .dim { - /* opacity: 0.7; */ + opacity: 0.7; } \ No newline at end of file diff --git a/src/windows/settings/Settings.svelte b/src/windows/settings/Settings.svelte index 488866ba..4cbb3a3b 100644 --- a/src/windows/settings/Settings.svelte +++ b/src/windows/settings/Settings.svelte @@ -1,7 +1,7 @@ - $focusedWindow = "settings"} /> + onDestroy(() => { + if (settingsFocusUnsub) settingsFocusUnsub(); + }); + -
+
@@ -138,6 +151,8 @@ align-items: center; color: var(--font-color); + + transition: opacity 0.1s ease-in-out; } .content { @@ -188,6 +203,6 @@ } .dim { - /* opacity: 0.7; */ + opacity: 0.7; } \ No newline at end of file