Skip to content

Commit

Permalink
fix: loading spinner now done properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Tormak9970 committed Apr 17, 2023
1 parent a333828 commit b0a7f01
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const steamKey = sharedStore("", "steamKey");

export const canSave = writable(false);
export const isOnline = writable(false);
export const loadingGames = writable(true);
export const currentPlatform: Writable<Platforms> = writable(Platforms.STEAM);
export const gridType: Writable<GridTypes> = writable(GridTypes.CAPSULE);

Expand Down
4 changes: 2 additions & 2 deletions src/components/core/games/Games.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { onDestroy, onMount } from "svelte";
import { Pane } from "svelte-splitpanes";
import type { Unsubscriber } from "svelte/store";
import { Platforms, currentPlatform, gridType, hiddenGameIds, nonSteamGames, selectedGameAppId, selectedGameName, selectedSteamGridGame, showHidden, steamGames } from "../../../Stores";
import { Platforms, currentPlatform, gridType, hiddenGameIds, loadingGames, nonSteamGames, selectedGameAppId, selectedGameName, selectedSteamGridGame, showHidden, steamGames } from "../../../Stores";
import LoadingSpinner from "../../info/LoadingSpinner.svelte";
import SearchBar from "../../interactables/SearchBar.svelte";
import Toggle from "../../interactables/Toggle.svelte";
Expand Down Expand Up @@ -123,7 +123,7 @@
<VerticalSpacer />
<VerticalSpacer />

{#if isLoading || games.length == 0}
{#if isLoading || $loadingGames}
<div class="loader-container">
<LoadingSpinner />
</div>
Expand Down
17 changes: 11 additions & 6 deletions src/lib/controllers/AppController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ToastController } from "./ToastController";
import { SettingsManager } from "../utils/SettingsManager";
import { LogController } from "./LogController";
import { get } from "svelte/store";
import { GridTypes, Platforms, activeUserId, appLibraryCache, canSave, currentPlatform, gridType, hiddenGameIds, isOnline, needsSGDBAPIKey, needsSteamKey, nonSteamGames, originalAppLibraryCache, originalSteamShortcuts, selectedGameAppId, selectedGameName, steamGames, steamGridDBKey, steamKey, steamShortcuts, steamUsers } from "../../Stores";
import { GridTypes, Platforms, activeUserId, appLibraryCache, canSave, currentPlatform, gridType, hiddenGameIds, isOnline, loadingGames, needsSGDBAPIKey, needsSteamKey, nonSteamGames, originalAppLibraryCache, originalSteamShortcuts, selectedGameAppId, selectedGameName, steamGames, steamGridDBKey, steamKey, steamShortcuts, steamUsers } from "../../Stores";
import { CacheController } from "./CacheController";
import { RustInterop } from "./RustInterop";
import type { SGDBImage } from "../models/SGDB";
Expand Down Expand Up @@ -112,7 +112,10 @@ export class AppController {
const appIsOnline = get(isOnline);
LogController.log(`App loaded. IsOnline: ${appIsOnline}.`);

AppController.getUserApps();
loadingGames.set(true);
AppController.getUserApps().then(() => {
loadingGames.set(false);
});

if (get(needsSGDBAPIKey)) {
WindowController.openSettingsWindow();
Expand Down Expand Up @@ -583,10 +586,12 @@ export class AppController {
});
}

await AppController.getUserApps();

LogController.log(`Switched user to ${user.AccountName} id: ${userId}.`);
ToastController.showSuccessToast("Switched User!");
loadingGames.set(true);
AppController.getUserApps().then(() => {
loadingGames.set(false);
LogController.log(`Switched user to ${user.AccountName} id: ${userId}.`);
ToastController.showSuccessToast("Switched User!");
});
} else {
LogController.log(`Cancelled user switch to ${user.AccountName} id: ${userId}.`);
ToastController.showGenericToast("Cancelled.");
Expand Down

0 comments on commit b0a7f01

Please sign in to comment.