Skip to content

Commit

Permalink
fix: changes now apply after multiple saves
Browse files Browse the repository at this point in the history
  • Loading branch information
Tormak9970 committed Apr 14, 2023
1 parent 56220a7 commit 6c9f979
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/controllers/AppController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ export class AppController {
const libraryCache = get(appLibraryCache);
const shortcuts = get(steamShortcuts);
const shortcutIds = Object.values(shortcuts).map((shortcut) => shortcut.appid.toString());

const changedPaths = await RustInterop.saveChanges(libraryCache, originalCache, shortcuts, shortcutIds);

if ((changedPaths as any).error !== undefined) {
Expand All @@ -347,7 +348,7 @@ export class AppController {
for (const changedPath of (changedPaths as ChangedPath[])) {
libraryCache[changedPath.appId][changedPath.gridType] = changedPath.targetPath;
}
originalAppLibraryCache.set(libraryCache);
originalAppLibraryCache.set(JSON.parse(JSON.stringify(libraryCache)));
appLibraryCache.set(libraryCache);
ToastController.showSuccessToast("Changes saved!");
LogController.log("Saved changes.");
Expand All @@ -361,8 +362,8 @@ export class AppController {
* ? Logging complete.
*/
static async discardChanges(): Promise<void> {
const originalImgs = get(originalAppLibraryCache);
appLibraryCache.set({...originalImgs});
const originalCache = get(originalAppLibraryCache);
appLibraryCache.set(JSON.parse(JSON.stringify(originalCache)));

ToastController.showSuccessToast("Changes discarded!");
LogController.log("Discarded changes.");
Expand Down

0 comments on commit 6c9f979

Please sign in to comment.