Skip to content

Commit

Permalink
Merge pull request #189 from Tormak9970/dev
Browse files Browse the repository at this point in the history
chore: make new debug release
  • Loading branch information
Tormak9970 authored May 11, 2024
2 parents 82d48ea + b338541 commit 443ab9b
Show file tree
Hide file tree
Showing 22 changed files with 120 additions and 110 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "steam-art-manager",
"version": "3.6.2",
"version": "3.6.4",
"private": true,
"type": "module",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion public/theme.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Steam Art Manager is a tool for setting the artwork of your Steam library.
* Copyright (C) 2023 Travis Lane (Tormak)
* Copyright (C) 2024 Travis Lane (Tormak)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
16 changes: 1 addition & 15 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -537,22 +537,8 @@ async fn clean_grids(app_handle: AppHandle, steam_path: String, steam_active_use
#[tauri::command]
// Validates the steam install path
async fn validate_steam_path(app_handle: AppHandle, target_path: String) -> bool {
let pre_canonicalized_path: PathBuf = PathBuf::from(&target_path);

if !pre_canonicalized_path.exists() {
logger::log_to_core_file(app_handle.to_owned(), format!("{} does not exist, can't be a valid steam install.", target_path).as_str(), 1);
return false;
}

let steam_path_res = pre_canonicalized_path.canonicalize();

if steam_path_res.is_err() {
let path_err = steam_path_res.err().expect("Should have been able to get path res error here.");
logger::log_to_core_file(app_handle.to_owned(), format!("Error canonicalizing provided path: {}.", path_err.to_string()).as_str(), 1);
return false;
}
let steam_path: PathBuf = PathBuf::from(&target_path);

let steam_path = steam_path_res.ok().expect("Path should have been ok here.");
let steam_path_str: String = steam_path.to_str().expect("Should have been able to convert pathbuf to string").to_owned();

add_path_to_scope(app_handle, steam_path_str).await;
Expand Down
4 changes: 4 additions & 0 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"/var/home/*/.config/dev.tormak.steam-art-manager/**",
"$Home/**",
"/var/home/*/**",
"/home/*/.steam/**",
"/home/*/.local/share/steam/**",
"$DATA",
"$DATA/**",
"$APPLOG",
Expand Down Expand Up @@ -63,6 +65,8 @@
"/var/home/*/.config/dev.tormak.steam-art-manager/**",
"$Home/**",
"/var/home/*/**",
"/home/*/.steam/**",
"/home/*/.local/share/steam/**",
"$DATA",
"$DATA/**",
"$APPLOG",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/wix/short-license.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Steam Art Manager is a tool for setting the artwork of your Steam library.
Copyright (C) 2023 Travis Lane (Tormak)
Copyright (C) 2024 Travis Lane (Tormak)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
50 changes: 27 additions & 23 deletions src/components/core/grids/GridResults.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { AppController } from "../../../lib/controllers/AppController";
import type { SGDBImage } from "../../../lib/models/SGDB";
import { dbFilters, gridType, GridTypes, isOnline, needsSGDBAPIKey, selectedGameAppId, selectedGameName, steamGridDBKey, selectedSteamGridGameId, lastPageCache, hasMorePagesCache, loadingSettings } from "../../../stores/AppState";
import { dbFilters, gridType, GridTypes, isOnline, needsSGDBAPIKey, selectedGameAppId, selectedGameName, steamGridDBKey, selectedSteamGridGameId, lastPageCache, hasMorePagesCache, loadingSettings, steamGridSearchCache } from "../../../stores/AppState";
import Grid from "./Grid.svelte";
import { debounce, filterGrids, getHasMorePages, getPageNumberForGame } from "../../../lib/utils/Utils";
import GridLoadingSkeleton from "../../layout/GridLoadingSkeleton.svelte";
Expand All @@ -23,31 +23,27 @@
/**
* Filters the grids based when relevant state changes.
* @param resultsPage The results page to show.
* @param isCustomName Whether the app name is custom or not.
*/
async function filterGridsOnStateChange(resultsPage: number, isCustomName: boolean = false): Promise<void> {
if ($isOnline && $steamGridDBKey !== "" && !!$selectedGameAppId) {
const unfilteredGrids = await AppController.getSteamGridArt($selectedGameAppId, resultsPage, $selectedSteamGridGameId, isCustomName);
grids = filterGrids(unfilteredGrids, $gridType, $dbFilters, $selectedGameName);
console.log("grids length:", grids.length);
console.log("as set:", (new Set(grids)).size);
// TODO: easy fix would be make it a set but the issue is something else is going wrong
}
async function filterGridsOnStateChange(resultsPage: number): Promise<void> {
const unfilteredGrids = await AppController.getSteamGridArt($selectedGameAppId, resultsPage, $selectedSteamGridGameId);
grids = filterGrids(unfilteredGrids, $gridType, $dbFilters, $selectedGameName, resultsPage);
}
/**
* Handles loading new grids when the user scrolls to the bottom.
*/
async function handleLoadOnScroll() {
const lastPageLoaded = getPageNumberForGame($selectedSteamGridGameId, $gridType);
const oldGridsLength = grids.length;
await filterGridsOnStateChange(lastPageLoaded + 1, hasCustomName);
if (oldGridsLength !== grids.length) {
lastPageCache[parseInt($selectedSteamGridGameId)][$gridType] = lastPageLoaded + 1;
} else {
hasMorePagesCache[parseInt($selectedSteamGridGameId)][$gridType] = false;
hasMorePages = false;
if ($isOnline && $steamGridDBKey !== "" && !!$selectedGameAppId) {
const lastPageLoaded = getPageNumberForGame($selectedSteamGridGameId, $gridType);
const oldGridsLength = grids.length;
await filterGridsOnStateChange(lastPageLoaded + 1);
if (oldGridsLength !== grids.length) {
lastPageCache[parseInt($selectedSteamGridGameId)][$gridType] = lastPageLoaded + 1;
} else {
hasMorePagesCache[parseInt($selectedSteamGridGameId)][$gridType] = false;
hasMorePages = false;
}
}
}
Expand All @@ -59,9 +55,17 @@
const debouncedResize = debounce(handleResize, 500);
onMount(() => {
filterGridsOnStateChange(getPageNumberForGame($selectedSteamGridGameId, $gridType), hasCustomName).then(() => {
isLoading = false;
});
if ($selectedGameAppId) {
if ($selectedSteamGridGameId === "None") {
AppController.chooseSteamGridGameId($selectedGameAppId, hasCustomName).then((sgdbGameId) => {
$selectedSteamGridGameId = sgdbGameId;
});
} else {
handleLoadOnScroll().then(() => {
isLoading = false;
});
}
}
});
</script>

Expand All @@ -85,7 +89,7 @@
</div>
{:else}
<div class="message">
No results for {$gridType === GridTypes.HERO ? "Heroe" : $gridType}s for "{$selectedGameName}".
No results for {$gridType === GridTypes.HERO ? "Heroe" : $gridType}s for "{$steamGridSearchCache[$selectedGameAppId].find((game) => game.id.toString() === $selectedSteamGridGameId).name}".
</div>
{/if}
{/if}
Expand Down
28 changes: 12 additions & 16 deletions src/components/core/grids/Grids.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
import GridResults from "./GridResults.svelte";
let windowWidth: number;
let skipUpdate = false;
let selectedAppIdUnsub: Unsubscriber;
let steamGridSearchCacheUnsub: Unsubscriber;
let manualGamesUnsub: Unsubscriber;
let customGameNamesUnsub: Unsubscriber;
let selectedPlatformUnsub: Unsubscriber;
let apiKeyUnsub: Unsubscriber;
let isLoading = false;
let availableSteamGridGames = [ { label: "None", data: "None" } ];
let steamGridTypes = Object.values(GridTypes).map((gridType) => { return { label: gridType, data: gridType }});
let hasCustomName = !!$customGameNames[$selectedGameAppId];
Expand All @@ -40,7 +39,6 @@
if ($customGameNames[$selectedGameAppId] && res.name === originalName) {
delete $customGameNames[$selectedGameAppId];
} else {
skipUpdate = true;
$customGameNames[$selectedGameAppId] = res.name;
}
Expand Down Expand Up @@ -115,19 +113,16 @@
});
customGameNamesUnsub = customGameNames.subscribe(async (customNames) => {
if (!skipUpdate) {
if (customNames[$selectedGameAppId] && !hasCustomName) {
hasCustomName = true;
$selectedGameName = customNames[$selectedGameAppId];
delete $steamGridSearchCache[$selectedGameAppId];
} else if (!customNames[$selectedGameAppId] && hasCustomName) {
hasCustomName = false;
$selectedGameName = originalName;
delete $steamGridSearchCache[$selectedGameAppId];
}
} else {
skipUpdate = false;
}
hasCustomName = !customNames[$selectedGameAppId];
$selectedGameName = customNames[$selectedGameAppId] ?? originalName;
delete $steamGridSearchCache[$selectedGameAppId];
availableSteamGridGames = [ { label: "None", data: "None" } ];
$selectedSteamGridGameId = "None";
});
selectedAppIdUnsub = selectedGameAppId.subscribe(() => {
availableSteamGridGames = [ { label: "None", data: "None" } ];
$selectedSteamGridGameId = "None";
});
selectedPlatformUnsub = currentPlatform.subscribe((platform) => {
Expand All @@ -139,6 +134,7 @@
});
onDestroy(() => {
if (selectedAppIdUnsub) selectedAppIdUnsub();
if (steamGridSearchCacheUnsub) steamGridSearchCacheUnsub();
if (manualGamesUnsub) manualGamesUnsub();
if (customGameNamesUnsub) customGameNamesUnsub();
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/settings/SettingsModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
<div class="settings-container">
<FilePathEntry
label="Steam Install Path"
description={"The root of your Steam installation. The default on Windows is <b>C:/Program Files (x86)/Steam</b> and <b>~/.steam/Steam</b> on Linux. You must restart after changing this."}
description={"The root of your Steam installation. The default on Windows is <b>C:/Program Files (x86)/Steam</b> and <b>/home/deck/.steam/steam</b> on Linux. You must restart after changing this."}
value={steamInstallLocation}
onChange={onInstallLocationChange}
useValidator
Expand Down
18 changes: 14 additions & 4 deletions src/lib/controllers/AppController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Steam Art Manager is a tool for setting the artwork of your Steam library.
* Copyright (C) 2023 Travis Lane (Tormak)
* Copyright (C) 2024 Travis Lane (Tormak)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -488,17 +488,27 @@ export class AppController {
}
}

/**
* Chooses the steam grid game id for the provided game.
* @param appId The id of the app to get.
* @param isCustomName Whether the app name is custom or not.
* @returns A promise resolving to the id.
* ? Logging complete.
*/
static async chooseSteamGridGameId(appId: number, isCustomName: boolean): Promise<string> {
return await AppController.cacheController.chooseSteamGridGameId(appId, get(selectedGameName), get(currentPlatform), true, isCustomName);
}

/**
* Gets a list of grids for the provided game.
* @param appId The id of the app to get.
* @param page The page of results to get.
* @param selectedSteamGridId Optional id of the current steamGridGame.
* @param isCustomName Whether the app name is custom or not.
* @returns A promise resolving to a list of the results.
* ? Logging complete.
*/
static async getSteamGridArt(appId: number, page: number, selectedSteamGridId: string | null, isCustomName: boolean): Promise<SGDBImage[]> {
return await AppController.cacheController.fetchGrids(appId, get(selectedGameName), page, get(currentPlatform), true, selectedSteamGridId, isCustomName);
static async getSteamGridArt(appId: number, page: number, selectedSteamGridId: string | null): Promise<SGDBImage[]> {
return await AppController.cacheController.fetchGrids(appId, page, true, selectedSteamGridId);
}

/**
Expand Down
Loading

0 comments on commit 443ab9b

Please sign in to comment.