From 159ca2b9c9a7d14c53b640599f439077a0e2f2a9 Mon Sep 17 00:00:00 2001 From: Jesse Bofill Date: Thu, 1 Feb 2024 10:51:28 -0700 Subject: [PATCH] fix: fixes bug where error occurs when applying profile 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. --- src/components/CustomTabContainer.tsx | 44 +++++++++++++-------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/components/CustomTabContainer.tsx b/src/components/CustomTabContainer.tsx index 71e7d67..6bbd3e3 100644 --- a/src/components/CustomTabContainer.tsx +++ b/src/components/CustomTabContainer.tsx @@ -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(); - appsList.forEach((appItem: SteamAppOverview) => appMap.set(appItem.appid, allAppsMap.get(appItem.appid)!)); + const allAppsMap = collectionStore.allAppsCollection.apps; + const appMap = new Map(); + appsList.forEach((appItem: SteamAppOverview) => appMap.set(appItem.appid, allAppsMap.get(appItem.appid)!)); - this.collection.apps = appMap; - } + this.collection.apps = appMap; } /**