From 3da557c72deedfe26766ea53504ca8f3336aada2 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sun, 8 Feb 2026 10:05:35 -0500 Subject: [PATCH] load stores dierctly in roms store --- .../Gallery/AppBar/common/CharIndexBar.vue | 6 ------ .../AppBar/common/FilterDrawer/Base.vue | 2 -- .../LibraryManagement/Config/MissingGames.vue | 12 ++--------- .../components/common/Game/VirtualTable.vue | 5 +---- frontend/src/console/views/GamesList.vue | 2 -- frontend/src/stores/roms.ts | 15 +++++++------ .../Gallery/Collection/BaseCollection.vue | 7 +------ frontend/src/views/Gallery/Platform.vue | 5 +---- frontend/src/views/Gallery/Search.vue | 21 +++++++------------ 9 files changed, 19 insertions(+), 56 deletions(-) diff --git a/frontend/src/components/Gallery/AppBar/common/CharIndexBar.vue b/frontend/src/components/Gallery/AppBar/common/CharIndexBar.vue index b474c6380..ab51e4107 100644 --- a/frontend/src/components/Gallery/AppBar/common/CharIndexBar.vue +++ b/frontend/src/components/Gallery/AppBar/common/CharIndexBar.vue @@ -3,16 +3,12 @@ import type { Emitter } from "mitt"; import { storeToRefs } from "pinia"; import { inject, watch, computed } from "vue"; import { useDisplay } from "vuetify"; -import storeGalleryFilter from "@/stores/galleryFilter"; import storeGalleryView from "@/stores/galleryView"; -import storePlatforms from "@/stores/platforms"; import storeRoms from "@/stores/roms"; import type { Events } from "@/types/emitter"; const { smAndDown } = useDisplay(); const romsStore = storeRoms(); -const platformsStore = storePlatforms(); -const galleryFilterStore = storeGalleryFilter(); const galleryViewStore = storeGalleryView(); const { selectedRoms } = storeToRefs(romsStore); const emitter = inject>("emitter"); @@ -32,8 +28,6 @@ async function fetchRoms() { romsStore .fetchRoms({ - galleryFilter: galleryFilterStore, - platformsStore: platformsStore, concat: false, }) .then(() => { diff --git a/frontend/src/components/Gallery/AppBar/common/FilterDrawer/Base.vue b/frontend/src/components/Gallery/AppBar/common/FilterDrawer/Base.vue index 884dd5395..37166c3e1 100644 --- a/frontend/src/components/Gallery/AppBar/common/FilterDrawer/Base.vue +++ b/frontend/src/components/Gallery/AppBar/common/FilterDrawer/Base.vue @@ -87,8 +87,6 @@ const onFilterChange = debounce( () => { romsStore.resetPagination(); romsStore.fetchRoms({ - galleryFilter: galleryFilterStore, - platformsStore: platformsStore, concat: false, }); diff --git a/frontend/src/components/Settings/LibraryManagement/Config/MissingGames.vue b/frontend/src/components/Settings/LibraryManagement/Config/MissingGames.vue index 6dc35db29..d8fe91fef 100644 --- a/frontend/src/components/Settings/LibraryManagement/Config/MissingGames.vue +++ b/frontend/src/components/Settings/LibraryManagement/Config/MissingGames.vue @@ -44,8 +44,6 @@ const onFilterChange = debounce( romsStore.resetPagination(); galleryFilterStore.setFilterMissing(true); romsStore.fetchRoms({ - galleryFilter: galleryFilterStore, - platformsStore: platformsStore, concat: false, }); @@ -75,10 +73,7 @@ async function fetchRoms() { galleryFilterStore.setFilterMissing(true); romsStore - .fetchRoms({ - galleryFilter: galleryFilterStore, - platformsStore: platformsStore, - }) + .fetchRoms({}) .catch((error) => { console.error("Error fetching missing games:", error); emitter?.emit("snackbarShow", { @@ -98,10 +93,7 @@ function cleanupAll() { romsStore.setLimit(10000); galleryFilterStore.setFilterMissing(true); romsStore - .fetchRoms({ - galleryFilter: galleryFilterStore, - platformsStore: platformsStore, - }) + .fetchRoms({}) .then(() => { emitter?.emit("showLoadingDialog", { loading: false, diff --git a/frontend/src/components/common/Game/VirtualTable.vue b/frontend/src/components/common/Game/VirtualTable.vue index 1a14903de..460b4bdab 100644 --- a/frontend/src/components/common/Game/VirtualTable.vue +++ b/frontend/src/components/common/Game/VirtualTable.vue @@ -136,10 +136,7 @@ function updateOptions({ sortBy }: { sortBy: SortBy }) { romsStore.resetPagination(); romsStore.setOrderBy(key); romsStore.setOrderDir(order); - romsStore.fetchRoms({ - galleryFilter: galleryFilterStore, - platformsStore: platformsStore, - }); + romsStore.fetchRoms({}); } diff --git a/frontend/src/console/views/GamesList.vue b/frontend/src/console/views/GamesList.vue index abccb18f5..10783f4f2 100644 --- a/frontend/src/console/views/GamesList.vue +++ b/frontend/src/console/views/GamesList.vue @@ -319,8 +319,6 @@ async function fetchRoms() { romsStore.resetPagination(); const fetchedRoms = await romsStore.fetchRoms({ - galleryFilter: galleryFilterStore, - platformsStore: platformsStore, concat: false, }); diff --git a/frontend/src/stores/roms.ts b/frontend/src/stores/roms.ts index 3954e2039..369726e6d 100644 --- a/frontend/src/stores/roms.ts +++ b/frontend/src/stores/roms.ts @@ -194,19 +194,18 @@ export default defineStore("roms", { } }, async fetchRoms({ - galleryFilter, - platformsStore, concat = true, }: { - galleryFilter: GalleryFilterStore; - platformsStore: PlatformsStore; concat?: boolean; }): Promise { if (this.fetchingRoms) return Promise.resolve([]); this.fetchingRoms = true; + const galleryFilterStore = storeGalleryFilter(); + const platformsStore = storePlatforms(); + // Capture current request parameters to validate background updates - const currentRequestParams = this._buildRequestParams(galleryFilter); + const currentRequestParams = this._buildRequestParams(galleryFilterStore); return new Promise((resolve, reject) => { cachedApiService @@ -214,14 +213,14 @@ export default defineStore("roms", { if (concat && this.fetchOffset != 0) return; // Check if parameters have changed since the request was made - const currentParams = this._buildRequestParams(galleryFilter); + const currentParams = this._buildRequestParams(galleryFilterStore); const paramsChanged = JSON.stringify(currentParams) !== JSON.stringify(currentRequestParams); if (paramsChanged) return; this._postFetchRoms( response, - galleryFilter, + galleryFilterStore, platformsStore, concat, ); @@ -229,7 +228,7 @@ export default defineStore("roms", { .then((response) => { this._postFetchRoms( response.data, - galleryFilter, + galleryFilterStore, platformsStore, concat, ); diff --git a/frontend/src/views/Gallery/Collection/BaseCollection.vue b/frontend/src/views/Gallery/Collection/BaseCollection.vue index 272a38407..d2ab345d6 100644 --- a/frontend/src/views/Gallery/Collection/BaseCollection.vue +++ b/frontend/src/views/Gallery/Collection/BaseCollection.vue @@ -15,7 +15,6 @@ import GameTable from "@/components/common/Game/VirtualTable.vue"; import { type CollectionType } from "@/stores/collections"; import storeGalleryFilter from "@/stores/galleryFilter"; import storeGalleryView from "@/stores/galleryView"; -import storePlatforms from "@/stores/platforms"; import storeRoms, { type SimpleRom } from "@/stores/roms"; import type { Events } from "@/types/emitter"; import { views } from "@/utils"; @@ -30,7 +29,6 @@ const galleryViewStore = storeGalleryView(); const galleryFilterStore = storeGalleryFilter(); const { scrolledToTop, currentView } = storeToRefs(galleryViewStore); const romsStore = storeRoms(); -const platformsStore = storePlatforms(); const { filteredRoms, selectedRoms, @@ -55,10 +53,7 @@ async function fetchRoms() { }); romsStore - .fetchRoms({ - galleryFilter: galleryFilterStore, - platformsStore: platformsStore, - }) + .fetchRoms({}) .then(() => { emitter?.emit("showLoadingDialog", { loading: false, diff --git a/frontend/src/views/Gallery/Platform.vue b/frontend/src/views/Gallery/Platform.vue index 75d1757ea..6dd6c7436 100644 --- a/frontend/src/views/Gallery/Platform.vue +++ b/frontend/src/views/Gallery/Platform.vue @@ -48,10 +48,7 @@ async function fetchRoms() { }); romsStore - .fetchRoms({ - galleryFilter: galleryFilterStore, - platformsStore: platformsStore, - }) + .fetchRoms({}) .then(() => { emitter?.emit("showLoadingDialog", { loading: false, diff --git a/frontend/src/views/Gallery/Search.vue b/frontend/src/views/Gallery/Search.vue index ccfa52487..50a45f8e6 100644 --- a/frontend/src/views/Gallery/Search.vue +++ b/frontend/src/views/Gallery/Search.vue @@ -13,7 +13,6 @@ import GameCard from "@/components/common/Game/Card/Base.vue"; import GameTable from "@/components/common/Game/VirtualTable.vue"; import storeGalleryFilter from "@/stores/galleryFilter"; import storeGalleryView from "@/stores/galleryView"; -import storePlatforms from "@/stores/platforms"; import storeRoms, { type SimpleRom } from "@/stores/roms"; import type { Events } from "@/types/emitter"; import { views } from "@/utils"; @@ -23,7 +22,6 @@ const { scrolledToTop, currentView } = storeToRefs(galleryViewStore); const galleryFilterStore = storeGalleryFilter(); const { searchTerm } = storeToRefs(galleryFilterStore); const romsStore = storeRoms(); -const platformsStore = storePlatforms(); const { filteredRoms, selectedRoms, @@ -101,19 +99,14 @@ function onGameTouchEnd() { } function fetchRoms() { - romsStore - .fetchRoms({ - galleryFilter: galleryFilterStore, - platformsStore: platformsStore, - }) - .catch((error) => { - emitter?.emit("snackbarShow", { - msg: `Couldn't fetch roms: ${error}`, - icon: "mdi-close-circle", - color: "red", - timeout: 4000, - }); + romsStore.fetchRoms({}).catch((error) => { + emitter?.emit("snackbarShow", { + msg: `Couldn't fetch roms: ${error}`, + icon: "mdi-close-circle", + color: "red", + timeout: 4000, }); + }); } const { y: windowY } = useScroll(window, { throttle: 500 });