fix(front): Move key extractor into datastore

2490-experimental-use-simple-data-store
Flupsi 2025-09-16 10:00:18 +02:00
rodzic f7d9fdf58e
commit 963fa22499
3 zmienionych plików z 7 dodań i 8 usunięć

Wyświetl plik

@ -4,7 +4,6 @@ import { useUploadsStore } from '../stores/upload'
import { useI18n } from 'vue-i18n'
import { useStore } from '~/store'
import { useModal } from '~/ui/composables/useModal.ts'
import { defineAsyncComponent } from 'vue'
import Logo from '~/components/Logo.vue'
import UserMenu from './UserMenu.vue'
@ -15,13 +14,9 @@ import PopoverItem from '~/components/ui/popover/PopoverItem.vue'
import Button from '~/components/ui/Button.vue'
import Layout from '~/components/ui/Layout.vue'
import Spacer from '~/components/ui/Spacer.vue'
import SearchModal from '~/ui/modals/Search.vue'
import { useRoute } from 'vue-router'
// simple usage
const SearchModal = defineAsyncComponent({
loader: () => import('~/ui/modals/Search.vue')
})
const isCollapsed = ref(true)
const route = useRoute()

Wyświetl plik

@ -12,8 +12,7 @@ import useErrorHandler from '~/composables/useErrorHandler'
import { useI18n } from 'vue-i18n'
import { useModal } from '~/ui/composables/useModal.ts'
import { useStore } from '~/store'
import { getKey } from '~/rstore/model'
import { useDataStore } from '~/ui/stores/data'
import { useDataStore, getKey } from '~/ui/stores/data'
import ArtistCard from '~/components/artist/Card.vue'
import PlaylistCard from '~/components/playlists/Card.vue'

Wyświetl plik

@ -14,6 +14,11 @@ import type { Album, Artist, Tag, Track } from '~/types'
const logger = useLogger()
/** @returns the most unique identifier available per item, assuming every item has at least one key field */
export const getKey = (item: { fid: string } | { artist: { fid: string } } | { id: number } | { name: string }) =>
'fid' in item ? item.fid : 'artist' in item ? item.artist.fid : 'id' in item ? item.id.toString() : item.name
// ======================================================================
// Object names
const names = [