Merge pull request #1561 from ItsKaa/fix-recently-added

fix: Remove sibling roms from Recently Added.
This commit is contained in:
Georges-Antoine Assi
2025-01-27 21:38:04 -05:00
committed by GitHub

View File

@@ -41,25 +41,16 @@ export default defineStore("roms", {
},
actions: {
_reorder() {
// Sort roms by comparator string
this.allRoms = uniqBy(this.allRoms, "id").sort((a, b) => {
return a.sort_comparator.localeCompare(b.sort_comparator);
});
// Check if roms should be grouped
const groupRoms = isNull(localStorage.getItem("settings.groupRoms"))
_shouldGroupRoms(): boolean {
return isNull(localStorage.getItem("settings.groupRoms"))
? true
: localStorage.getItem("settings.groupRoms") === "true";
if (!groupRoms) {
this._grouped = this.allRoms;
return;
}
// Group roms by external id
this._grouped = Object.values(
},
_getGroupedRoms(roms: SimpleRom[]): SimpleRom[] {
// Group roms by external id.
return Object.values(
groupBy(
this.allRoms,
roms,
(game) =>
// If external id is null, generate a random id so that the roms are not grouped
game.igdb_id || game.moby_id || nanoid(),
@@ -70,7 +61,22 @@ export default defineStore("roms", {
return (
games.find((game) => game.rom_user?.is_main_sibling) || games[0]
);
})
});
},
_reorder() {
// Sort roms by comparator string
this.allRoms = uniqBy(this.allRoms, "id").sort((a, b) => {
return a.sort_comparator.localeCompare(b.sort_comparator);
});
// Check if roms should be grouped
if (!this._shouldGroupRoms()) {
this._grouped = this.allRoms;
return;
}
// Group roms by external id
this._grouped = this._getGroupedRoms(this.allRoms)
.sort((a, b) => {
return a.sort_comparator.localeCompare(b.sort_comparator);
});
@@ -82,7 +88,15 @@ export default defineStore("roms", {
this.currentRom = rom;
},
setRecentRoms(roms: SimpleRom[]) {
this.recentRoms = roms;
if (this._shouldGroupRoms()) {
// Group by external ID to only display a single entry per sibling,
// and sorted on rom ID in descending order.
this.recentRoms = this._getGroupedRoms(roms).sort(
(a, b) => b.id - a.id
);
} else {
this.recentRoms = roms;
}
},
setContinuePlayedRoms(roms: SimpleRom[]) {
this.continuePlayingRoms = roms;