Skip to content

Commit

Permalink
fix: fixes bug where error occurs when applying profile
Browse files Browse the repository at this point in the history
this bug occurs when applying a profile that has hidden tabs
that have not yet had their collections built.
this change now builds all tabs (including hidden) collections when the plugin loads.
  • Loading branch information
jessebofill committed Feb 1, 2024
1 parent 6d4d09e commit 159ca2b
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions src/components/CustomTabContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,33 +79,31 @@ export class CustomTabContainer implements TabContainer {
* Builds the list of apps for this tab.
*/
buildCollection() {
if (this.position > -1) {
const {hidden, ...catsToIncludeObj} = getIncludedCategoriesFromBitField(this.categoriesToInclude);
const visibility = hidden ? "allApps" : "visibleApps";
let listToFilter: SteamAppOverview[] = [];

for (const key in catsToIncludeObj) {
const category = key as keyof typeof catsToIncludeObj;
if (catsToIncludeObj[category]) listToFilter = listToFilter.concat(collectionStore.appTypeCollectionMap.get(`type-${category}`)![visibility]);
const { hidden, ...catsToIncludeObj } = getIncludedCategoriesFromBitField(this.categoriesToInclude);
const visibility = hidden ? "allApps" : "visibleApps";
let listToFilter: SteamAppOverview[] = [];

for (const key in catsToIncludeObj) {
const category = key as keyof typeof catsToIncludeObj;
if (catsToIncludeObj[category]) listToFilter = listToFilter.concat(collectionStore.appTypeCollectionMap.get(`type-${category}`)![visibility]);
}

const appsList = listToFilter.filter(appItem => {
if (this.filtersMode === 'and') {
return this.filters.every(filterSettings => Filter.run(filterSettings, appItem));
} else {
return this.filters.some(filterSettings => Filter.run(filterSettings, appItem));
}

const appsList = listToFilter.filter(appItem => {
if (this.filtersMode === 'and') {
return this.filters.every(filterSettings => Filter.run(filterSettings, appItem));
} else {
return this.filters.some(filterSettings => Filter.run(filterSettings, appItem));
}
});
});

this.collection.allApps = appsList;
this.collection.visibleApps = [...appsList];
this.collection.allApps = appsList;
this.collection.visibleApps = [...appsList];

const allAppsMap = collectionStore.allAppsCollection.apps;
const appMap = new Map<AppId, SteamAppOverview>();
appsList.forEach((appItem: SteamAppOverview) => appMap.set(appItem.appid, allAppsMap.get(appItem.appid)!));
const allAppsMap = collectionStore.allAppsCollection.apps;
const appMap = new Map<AppId, SteamAppOverview>();
appsList.forEach((appItem: SteamAppOverview) => appMap.set(appItem.appid, allAppsMap.get(appItem.appid)!));

this.collection.apps = appMap;
}
this.collection.apps = appMap;
}

/**
Expand Down

0 comments on commit 159ca2b

Please sign in to comment.