mirror of
https://github.com/rommapp/romm.git
synced 2026-02-19 07:50:57 +01:00
use platofrm store on gallery page
This commit is contained in:
@@ -8,6 +8,7 @@ import romApi from "@/services/api/rom";
|
||||
import storeGalleryFilter from "@/stores/galleryFilter";
|
||||
import storeGalleryView from "@/stores/galleryView";
|
||||
import storeRoms from "@/stores/roms";
|
||||
import storePlatforms from "@/stores/platforms";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import type { RomSelectEvent } from "@/types/rom";
|
||||
import { normalizeString, toTop, views } from "@/utils";
|
||||
@@ -33,6 +34,7 @@ const {
|
||||
searchCursor,
|
||||
platform,
|
||||
} = storeToRefs(romsStore);
|
||||
const platforms = storePlatforms();
|
||||
|
||||
// Event listeners bus
|
||||
const emitter = inject<Emitter<Events>>("emitter");
|
||||
@@ -184,9 +186,17 @@ function onScroll() {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const { data: platform } = await platformApi.getPlatform(
|
||||
Number(route.params.platform)
|
||||
);
|
||||
const platform = platforms.get(Number(route.params.platform));
|
||||
if (!platform) {
|
||||
emitter?.emit("snackbarShow", {
|
||||
msg: `Platform ${route.params.platform} not found`,
|
||||
icon: "mdi-close-circle",
|
||||
color: "red",
|
||||
timeout: 4000,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
romsStore.setPlatform(platform);
|
||||
|
||||
// If platform is different, reset store and fetch roms
|
||||
@@ -219,9 +229,17 @@ onBeforeRouteUpdate(async (to, _) => {
|
||||
// Triggers when change query param of the same route
|
||||
// Reset store if switching to another platform
|
||||
resetGallery();
|
||||
const { data: newPlatform } = await platformApi.getPlatform(
|
||||
Number(to.params.platform)
|
||||
);
|
||||
const newPlatform = platforms.get(Number(route.params.platform));
|
||||
if (!newPlatform) {
|
||||
emitter?.emit("snackbarShow", {
|
||||
msg: `Platform ${route.params.platform} not found`,
|
||||
icon: "mdi-close-circle",
|
||||
color: "red",
|
||||
timeout: 4000,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
romsStore.setPlatform(newPlatform);
|
||||
await fetchRoms();
|
||||
setFilters();
|
||||
|
||||
Reference in New Issue
Block a user