From 0728f01cd891ff767efb51d6f338a9d1e6dc3da1 Mon Sep 17 00:00:00 2001 From: Flupsi Date: Thu, 14 Aug 2025 14:41:05 +0200 Subject: [PATCH] feat(front): add data models for the Search modal fix --- front/src/rstore/model.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/front/src/rstore/model.ts b/front/src/rstore/model.ts index e36d30f09..6419d5f20 100644 --- a/front/src/rstore/model.ts +++ b/front/src/rstore/model.ts @@ -5,9 +5,9 @@ import type { Split } from 'type-fest' import type { components } from '~/generated/types' import type { paths } from '~/generated/types' -/** @returns the most unique identifier per item, assuming every item has at least one key field */ -export const getKey = (item: { fid: string } | { artist: { fid: string } }) => - 'fid' in item ? item.fid : item.artist.fid +/** @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 /** Models @@ -17,7 +17,11 @@ TODO: Describe relations (perhaps wait for OpenAPI plugin) */ export const models = [ defineItemType().model({ name: 'albums', getKey }), - defineItemType().model({ name: 'channels', getKey }) + defineItemType().model({ name: 'channels', getKey }), + defineItemType().model({ name: 'tracks', getKey }), + defineItemType().model({ name: 'playlists', getKey }), + defineItemType().model({ name: 'radios', getKey }), + defineItemType().model({ name: 'tags', getKey }), ] as const satisfies ModelList satisfies // Assert that the name is always the third segment in the API path: