make favourites collection reactive

This commit is contained in:
Zurdi
2024-07-05 18:56:55 +02:00
parent dabd6bcf83
commit a2b35cc61b
5 changed files with 10 additions and 4 deletions

View File

@@ -55,7 +55,9 @@ async function switchFromFavourites() {
favCollection.value.roms = favCollection.value.roms.filter(
(id) => id !== props.rom.id
);
romsStore.remove([props.rom]);
if (romsStore.currentCollection?.name.toLowerCase() == "favourites") {
romsStore.remove([props.rom]);
}
}
}
await collectionApi

View File

@@ -51,7 +51,9 @@ async function switchFromFavourites() {
favCollection.value.roms = favCollection.value.roms.filter(
(id) => id !== props.rom.id
);
romsStore.remove([props.rom]);
if (romsStore.currentCollection?.name.toLowerCase() == "favourites") {
romsStore.remove([props.rom]);
}
}
}
await collectionApi

View File

@@ -92,7 +92,7 @@ export default defineStore("roms", {
return a.sort_comparator.localeCompare(b.sort_comparator);
});
},
setCurrentPlatform(platform: Platform) {
setCurrentPlatform(platform: Platform | null) {
this.currentPlatform = platform;
},
setCurrentRom(rom: DetailedRom) {
@@ -101,7 +101,7 @@ export default defineStore("roms", {
setRecentRoms(roms: SimpleRom[]) {
this.recentRoms = roms;
},
setCurrentCollection(collection: Collection) {
setCurrentCollection(collection: Collection | null) {
this.currentCollection = collection;
},
set(roms: SimpleRom[]) {

View File

@@ -245,6 +245,7 @@ onBeforeRouteUpdate(async (to, from) => {
});
onBeforeUnmount(() => {
romsStore.setCurrentCollection(null);
window.removeEventListener("wheel", onScroll);
window.removeEventListener("scroll", onScroll);
});

View File

@@ -245,6 +245,7 @@ onBeforeRouteUpdate(async (to, from) => {
});
onBeforeUnmount(() => {
romsStore.setCurrentPlatform(null);
window.removeEventListener("wheel", onScroll);
window.removeEventListener("scroll", onScroll);
});