diff --git a/frontend/src/stores/platforms.test.ts b/frontend/src/stores/platforms.test.ts index 26c31625a..5fb7de100 100644 --- a/frontend/src/stores/platforms.test.ts +++ b/frontend/src/stores/platforms.test.ts @@ -2,11 +2,7 @@ import { createPinia, setActivePinia } from "pinia"; import { beforeEach, describe, expect, it } from "vitest"; import storePlatforms, { type Platform } from "@/stores/platforms"; -function platform( - id: number, - displayName: string, - romCount: number, -): Platform { +function platform(id: number, displayName: string, romCount: number): Platform { return { id, display_name: displayName, @@ -29,7 +25,7 @@ describe("platform store lists", () => { store.set([filled, empty]); + expect(store.allPlatforms).toEqual([empty, filled]); expect(store.filledPlatforms).toEqual([filled]); - expect(store.platformIndexPlatforms).toEqual([empty, filled]); }); }); diff --git a/frontend/src/stores/platforms.ts b/frontend/src/stores/platforms.ts index 74706f3ff..64f26ac2c 100644 --- a/frontend/src/stores/platforms.ts +++ b/frontend/src/stores/platforms.ts @@ -20,8 +20,6 @@ export default defineStore("platforms", { all .filter((p) => p.rom_count > 0) .sort((a, b) => a.display_name.localeCompare(b.display_name)), - platformIndexPlatforms: ({ allPlatforms: all }) => - [...all].sort((a, b) => a.display_name.localeCompare(b.display_name)), filteredPlatforms: ({ allPlatforms: all, filterText }) => all .filter( @@ -40,7 +38,7 @@ export default defineStore("platforms", { actions: { _reorder() { this.allPlatforms = uniqBy(this.allPlatforms, "id").sort((a, b) => { - return a.name.localeCompare(b.name); + return a.display_name.localeCompare(b.display_name); }); }, fetchPlatforms(): Promise { diff --git a/frontend/src/v2/views/PlatformsIndex.test.ts b/frontend/src/v2/views/PlatformsIndex.test.ts index 7790f2238..3f33af21a 100644 --- a/frontend/src/v2/views/PlatformsIndex.test.ts +++ b/frontend/src/v2/views/PlatformsIndex.test.ts @@ -1,7 +1,7 @@ import { mount } from "@vue/test-utils"; import { createPinia, setActivePinia } from "pinia"; -import { defineComponent, ref } from "vue"; import { beforeEach, describe, expect, it, vi } from "vitest"; +import { defineComponent, ref } from "vue"; import storePlatforms, { type Platform } from "@/stores/platforms"; import PlatformsIndex from "./PlatformsIndex.vue"; @@ -30,7 +30,7 @@ vi.mock("@/v2/components/Platforms/PlatformListRow.vue", () => ({ default: defineComponent({ props: ["displayName", "romCount"], template: - "
{{ displayName }} {{ romCount }}
", + '
{{ displayName }} {{ romCount }}
', }), })); @@ -38,21 +38,21 @@ vi.mock("@/v2/components/Platforms/PlatformTile.vue", () => ({ default: defineComponent({ props: ["displayName", "romCount"], template: - "
{{ displayName }} {{ romCount }}
", + '
{{ displayName }} {{ romCount }}
', }), })); vi.mock("@/v2/components/shared/EmptyState.vue", () => ({ default: defineComponent({ props: ["message"], - template: "
{{ message }}
", + template: '
{{ message }}
', }), })); vi.mock("@/v2/components/shared/IndexShell.vue", () => ({ default: defineComponent({ template: - "
", + '
', }), })); @@ -88,11 +88,7 @@ vi.mock("@/v2/composables/useWrapGridNav", () => ({ useWrapGridNav: vi.fn(), })); -function platform( - id: number, - displayName: string, - romCount: number, -): Platform { +function platform(id: number, displayName: string, romCount: number): Platform { return { id, display_name: displayName, @@ -110,10 +106,7 @@ describe("PlatformsIndex", () => { it("renders empty database platforms so they remain reachable", () => { const platforms = storePlatforms(); - platforms.set([ - platform(2, "Nintendo 64", 12), - platform(1, "Game Boy", 0), - ]); + platforms.set([platform(2, "Nintendo 64", 12), platform(1, "Game Boy", 0)]); const wrapper = mount(PlatformsIndex); diff --git a/frontend/src/v2/views/PlatformsIndex.vue b/frontend/src/v2/views/PlatformsIndex.vue index 458835461..5ceb2796e 100644 --- a/frontend/src/v2/views/PlatformsIndex.vue +++ b/frontend/src/v2/views/PlatformsIndex.vue @@ -41,8 +41,7 @@ import { useWrapGridNav } from "@/v2/composables/useWrapGridNav"; const { t } = useI18n(); const platformsStore = storePlatforms(); -const { platformIndexPlatforms, fetchingPlatforms } = - storeToRefs(platformsStore); +const { allPlatforms, fetchingPlatforms } = storeToRefs(platformsStore); const { groupBy, layout } = useGalleryMode(); useGalleryViewModeUrl(); @@ -62,7 +61,7 @@ useWrapGridNav(gridRoot, { cellSelector: ".plat-tile" }); const playableById = computed(() => { const fn = isPlayable.value; const map = new Map(); - for (const p of platformIndexPlatforms.value) map.set(p.id, fn(p.slug)); + for (const p of allPlatforms.value) map.set(p.id, fn(p.slug)); return map; }); @@ -202,8 +201,8 @@ onMounted(() => { const filtered = computed(() => { const term = searchTerm.value.trim().toLowerCase(); - if (!term) return platformIndexPlatforms.value; - return platformIndexPlatforms.value.filter((p) => + if (!term) return allPlatforms.value; + return allPlatforms.value.filter((p) => p.display_name.toLowerCase().includes(term), ); }); @@ -223,7 +222,7 @@ const sortedForList = computed(() => { ); }); -const totalCount = computed(() => platformIndexPlatforms.value.length); +const totalCount = computed(() => allPlatforms.value.length); const noResults = computed( () => !fetchingPlatforms.value &&