Skip to content

Commit

Permalink
fixed empty categories not being deleted by remove all
Browse files Browse the repository at this point in the history
  • Loading branch information
cbartondock committed Apr 17, 2023
1 parent 905a3a3 commit 5d98a01
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 9 additions & 2 deletions src/lib/category-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ export class CategoryManager {
let toRemove = _.union(Object.keys(userData.apps).map((x)=>steam.shortenAppId(x)),extraneousShortIds).map((x)=>+x);
collections[catKey].added = collections[catKey].added.filter((appId: number) => toRemove.indexOf(appId)<0);
if(collections[catKey].added.length == 0 || removeAll) {
delete collections[catKey];
cats.remove(catKey);
// weirdly this works whereas delete collections[catKey] doesn't
collections[catKey] = {
id: catKey,
added: [],
removed: [],
};
}
}

Expand Down Expand Up @@ -94,7 +99,9 @@ export class CategoryManager {
}).catch((error: any)=>{
throw error;
})
.then(() => cats.save())
.then(() => {
cats.save()
})
.then(()=>{
localConfig.UserLocalConfigStore.WebStorage['user-collections'] = JSON.stringify(collections).replace(/"/g, '\\"');
const newVDF = genericParser.stringify(localConfig);
Expand Down
8 changes: 3 additions & 5 deletions src/lib/vdf-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,9 @@ export class VDF_Manager {
listItem.shortcuts.removeItem(appId);
listItem.addedItems.removeItem(appId);
listItem.screenshots.removeItem(appId);
listItem.screenshots.removeItem(ids.shortenAppId(appId));
listItem.screenshots.removeItem(ids.shortenAppId(appId).concat('p'));
listItem.screenshots.removeItem(ids.shortenAppId(appId).concat('_hero'));
listItem.screenshots.removeItem(ids.shortenAppId(appId).concat('_logo'));
listItem.screenshots.removeItem(ids.shortenAppId(appId).concat('_icon'));
for(let artworkType of artworkTypes) {
listItem.screenshots.removeItem(ids.shortenAppId(appId).concat(artworkIdDict[artworkType]))
}
}
listItem.addedItems.data = {};
});
Expand Down

0 comments on commit 5d98a01

Please sign in to comment.