diff --git a/frontend/src/components/Gallery/AppBar/common/FilterDrawer/Base.vue b/frontend/src/components/Gallery/AppBar/common/FilterDrawer/Base.vue index 93d75fc7b..957576fa4 100644 --- a/frontend/src/components/Gallery/AppBar/common/FilterDrawer/Base.vue +++ b/frontend/src/components/Gallery/AppBar/common/FilterDrawer/Base.vue @@ -1,6 +1,7 @@ + + diff --git a/frontend/src/components/Gallery/AppBar/common/FilterDrawer/FilterFavouritesBtn.vue b/frontend/src/components/Gallery/AppBar/common/FilterDrawer/FilterFavouritesBtn.vue index f6a8773d4..5db1adc87 100644 --- a/frontend/src/components/Gallery/AppBar/common/FilterDrawer/FilterFavouritesBtn.vue +++ b/frontend/src/components/Gallery/AppBar/common/FilterDrawer/FilterFavouritesBtn.vue @@ -31,7 +31,7 @@ function setFavourites() { 'text-romm-white': !filterFavourites, 'text-romm-accent-1': filterFavourites, }" - >Filter favouritesShow favourites diff --git a/frontend/src/components/Gallery/AppBar/common/FilterDrawer/FilterUnmatchedBtn.vue b/frontend/src/components/Gallery/AppBar/common/FilterDrawer/FilterUnmatchedBtn.vue index 96c0c290b..f7155d893 100644 --- a/frontend/src/components/Gallery/AppBar/common/FilterDrawer/FilterUnmatchedBtn.vue +++ b/frontend/src/components/Gallery/AppBar/common/FilterDrawer/FilterUnmatchedBtn.vue @@ -31,7 +31,7 @@ function setUnmatched() { 'text-romm-white': !filterUnmatched, 'text-romm-accent-1': filterUnmatched, }" - >Filter unmatchedShow unmatched diff --git a/frontend/src/stores/galleryFilter.ts b/frontend/src/stores/galleryFilter.ts index f79b361a1..d0b9ccca5 100644 --- a/frontend/src/stores/galleryFilter.ts +++ b/frontend/src/stores/galleryFilter.ts @@ -12,6 +12,7 @@ export default defineStore("galleryFilter", { filterCompanies: [] as string[], filterUnmatched: false, filterFavourites: false, + filterDuplicates: false, selectedGenre: null as string | null, selectedFranchise: null as string | null, selectedCollection: null as string | null, @@ -61,11 +62,18 @@ export default defineStore("galleryFilter", { disableFilterFavourites() { this.filterFavourites = false; }, + switchFilterDuplicates() { + this.filterDuplicates = !this.filterDuplicates; + }, + disableFilterDuplicates() { + this.filterDuplicates = false; + }, isFiltered() { return Boolean( normalizeString(this.filterSearch).trim() != "" || this.filterUnmatched || this.filterFavourites || + this.filterDuplicates || this.selectedGenre || this.selectedFranchise || this.selectedCollection || diff --git a/frontend/src/stores/roms.ts b/frontend/src/stores/roms.ts index 073a9e5a1..8628078df 100644 --- a/frontend/src/stores/roms.ts +++ b/frontend/src/stores/roms.ts @@ -45,10 +45,23 @@ export default defineStore("roms", { actions: { _reorder() { // Sort roms by comparator string - this.allRoms = this.allRoms.sort((a, b) => { - return a.sort_comparator.localeCompare(b.sort_comparator); - }); this.allRoms = uniqBy(this.allRoms, "id"); + this.allRoms = this.allRoms + .map((rom) => { + const siblings = this.allRoms + .filter((s) => s.id != rom.id) + .filter((s) => { + return ( + (rom.igdb_id && rom.igdb_id === s.igdb_id) || + (rom.moby_id && rom.moby_id === s.moby_id) + ); + }); + + return { ...rom, siblings }; + }) + .sort((a, b) => { + return a.sort_comparator.localeCompare(b.sort_comparator); + }); // Check if roms should be grouped const groupRoms = localStorage.getItem("settings.groupRoms") === "true"; @@ -160,6 +173,9 @@ export default defineStore("roms", { if (galleryFilter.filterFavourites) { this._filterFavourites(); } + if (galleryFilter.filterDuplicates) { + this._filterDuplicates(); + } if (galleryFilter.selectedGenre) { this._filterGenre(galleryFilter.selectedGenre); } @@ -192,6 +208,11 @@ export default defineStore("roms", { .filter((rom) => collectionStore.favCollection?.roms?.includes(rom.id)) .map((roms) => roms.id); }, + _filterDuplicates() { + this._filteredIDs = this.filteredRoms + .filter((rom) => rom.siblings?.length) + .map((rom) => rom.id); + }, _filterGenre(genreToFilter: string) { this._filteredIDs = this.filteredRoms .filter((rom) => rom.genres.some((genre) => genre === genreToFilter))