fix(tests): update snapshot

This commit is contained in:
Phan An 2024-07-05 14:20:30 +02:00
parent d4bf3cfb6c
commit 55543039e0
16 changed files with 47 additions and 47 deletions

View file

@ -1,7 +1,7 @@
// Vitest Snapshot v1
exports[`renders 1`] = `
<article data-v-2487c4e3="" class="full relative group flex max-w-full md:max-w-[256px] border p-5 rounded-lg flex-col gap-5 transition border-color duration-200" data-testid="artist-album-card" draggable="true" tabindex="0" title="IV by Led Zeppelin"><button data-v-40f79232="" data-v-2487c4e3="" class="thumbnail relative w-full aspect-square bg-no-repeat bg-cover bg-center overflow-hidden rounded-md active:scale-95" style="background-image: url(undefined/resources/assets/img/covers/default.svg);" data-testid="album-artist-thumbnail"><img data-v-40f79232="" alt="Thumbnail" src="http://loremflickr.com/640/480" class="w-full aspect-square object-cover" loading="lazy"><span data-v-40f79232="" class="hidden">Play all songs in the album IV</span><span data-v-40f79232="" class="absolute top-0 left-0 w-full h-full group-hover:bg-black/40 z-10"></span><span data-v-40f79232="" class="play-icon absolute flex opacity-0 items-center justify-center w-[32px] aspect-square rounded-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-k-highlight group-hover:opacity-100 duration-500 transition z-20"><br data-v-40f79232="" data-testid="Icon" icon="[object Object]" class="ml-1 text-white" size="lg"></span></button>
<article data-v-2487c4e3="" class="full relative group flex max-w-full md:max-w-[256px] border p-5 rounded-lg flex-col gap-5 transition border-color duration-200" data-testid="artist-album-card" draggable="true" tabindex="0" title="IV by Led Zeppelin"><button data-v-40f79232="" data-v-2487c4e3="" class="thumbnail relative w-full aspect-square bg-no-repeat bg-cover bg-center overflow-hidden rounded-md active:scale-95" style="background-image: url(undefined/resources/assets/img/covers/default.svg);" data-testid="album-artist-thumbnail"><img data-v-40f79232="" alt="Thumbnail" src="http://loremflickr.com/640/480" class="w-full aspect-square object-cover" loading="lazy"><span data-v-40f79232="" class="hidden">Play all songs in the album IV</span><span data-v-40f79232="" class="absolute top-0 left-0 w-full h-full group-hover:bg-black/40 no-hover:bg-black/40 z-10"></span><span data-v-40f79232="" class="play-icon absolute flex opacity-0 no-hover:opacity-100 items-center justify-center w-[32px] aspect-square rounded-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-k-highlight group-hover:opacity-100 duration-500 transition z-20"><br data-v-40f79232="" data-testid="Icon" icon="[object Object]" class="ml-0.5 text-white" size="lg"></span></button>
<footer data-v-2487c4e3="" class="flex flex-1 flex-col gap-1.5 overflow-hidden">
<div data-v-2487c4e3="" class="name flex flex-col gap-2 whitespace-nowrap"><a href="#/album/42" class="font-medium" data-testid="name">IV</a><a href="#/artist/17">Led Zeppelin</a></div>
<p data-v-2487c4e3="" class="meta text-[0.9rem] flex gap-1.5 opacity-70 hover:opacity-100"><a title="Shuffle all songs in the album IV" role="button"> Shuffle </a><a title="Download all songs in the album IV" role="button"> Download </a></p>

View file

@ -1,7 +1,7 @@
// Vitest Snapshot v1
exports[`renders 1`] = `
<article data-v-2487c4e3="" class="full relative group flex max-w-full md:max-w-[256px] border p-5 rounded-lg flex-col gap-5 transition border-color duration-200" data-testid="artist-album-card" draggable="true" tabindex="0" title="Led Zeppelin"><button data-v-40f79232="" data-v-2487c4e3="" class="thumbnail relative w-full aspect-square bg-no-repeat bg-cover bg-center overflow-hidden rounded-md active:scale-95" style="background-image: url(undefined/resources/assets/img/covers/default.svg);" data-testid="album-artist-thumbnail"><img data-v-40f79232="" alt="Thumbnail" src="foo.jpg" class="w-full aspect-square object-cover" loading="lazy"><span data-v-40f79232="" class="hidden">Play all songs by Led Zeppelin</span><span data-v-40f79232="" class="absolute top-0 left-0 w-full h-full group-hover:bg-black/40 z-10"></span><span data-v-40f79232="" class="play-icon absolute flex opacity-0 items-center justify-center w-[32px] aspect-square rounded-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-k-highlight group-hover:opacity-100 duration-500 transition z-20"><br data-v-40f79232="" data-testid="Icon" icon="[object Object]" class="ml-1 text-white" size="lg"></span></button>
<article data-v-2487c4e3="" class="full relative group flex max-w-full md:max-w-[256px] border p-5 rounded-lg flex-col gap-5 transition border-color duration-200" data-testid="artist-album-card" draggable="true" tabindex="0" title="Led Zeppelin"><button data-v-40f79232="" data-v-2487c4e3="" class="thumbnail relative w-full aspect-square bg-no-repeat bg-cover bg-center overflow-hidden rounded-md active:scale-95" style="background-image: url(undefined/resources/assets/img/covers/default.svg);" data-testid="album-artist-thumbnail"><img data-v-40f79232="" alt="Thumbnail" src="foo.jpg" class="w-full aspect-square object-cover" loading="lazy"><span data-v-40f79232="" class="hidden">Play all songs by Led Zeppelin</span><span data-v-40f79232="" class="absolute top-0 left-0 w-full h-full group-hover:bg-black/40 no-hover:bg-black/40 z-10"></span><span data-v-40f79232="" class="play-icon absolute flex opacity-0 no-hover:opacity-100 items-center justify-center w-[32px] aspect-square rounded-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-k-highlight group-hover:opacity-100 duration-500 transition z-20"><br data-v-40f79232="" data-testid="Icon" icon="[object Object]" class="ml-0.5 text-white" size="lg"></span></button>
<footer data-v-2487c4e3="" class="flex flex-1 flex-col gap-1.5 overflow-hidden">
<div data-v-2487c4e3="" class="name flex flex-col gap-2 whitespace-nowrap"><a href="#/artist/42" class="font-medium" data-testid="name">Led Zeppelin</a></div>
<p data-v-2487c4e3="" class="meta text-[0.9rem] flex gap-1.5 opacity-70 hover:opacity-100"><a title="Shuffle all songs by Led Zeppelin" role="button"> Shuffle </a><a title="Download all songs by Led Zeppelin" role="button"> Download </a></p>

View file

@ -3,7 +3,7 @@
exports[`renders without a current song 1`] = `
<aside data-v-847f0b60="" class="fixed sm:relative top-0 w-screen md:w-auto flex flex-col md:flex-row-reverse z-[2] text-k-text-secondary">
<div data-v-847f0b60="" class="controls flex md:flex-col justify-between items-center md:w-[64px] md:py-6 tw:px-0 bg-black/5 md:border-l border-solid md:border-l-white/5 md:border-b-0 md:shadow-none z-[2] w-screen flex-row border-b border-b-white/5 border-l-0 shadow-xl py-0 px-6 h-k-header-height">
<div data-v-847f0b60="" class="btn-group"><button data-v-5e31283f="" data-v-847f0b60="" class="relative flex items-center justify-center h-[42px] aspect-square rounded-full bg-none md:bg-black/30 text-xl opacity-70 transition-opacity duration-200 ease-in-out text-current cursor-pointer hover:active-state active:scale-90 block md:hidden" type="button"><br data-testid="Icon" icon="[object Object]"></button>
<div data-v-847f0b60="" class="btn-group"><button data-v-5e31283f="" data-v-847f0b60="" class="relative flex items-center justify-center h-[42px] aspect-square rounded-full bg-none md:bg-black/30 text-xl opacity-70 transition-opacity duration-200 ease-in-out text-current cursor-pointer hover:active-state active:scale-90 block md:hidden" type="button"><br data-testid="Icon" icon="[object Object]" fixed-width=""></button>
<!--v-if-->
</div>
<div data-v-847f0b60="" class="btn-group"><button data-v-5e31283f="" data-v-847f0b60="" class="relative flex items-center justify-center h-[42px] aspect-square rounded-full bg-none md:bg-black/30 text-xl opacity-70 transition-opacity duration-200 ease-in-out text-current cursor-pointer hover:active-state active:scale-90" type="button" title="About Koel"><br data-testid="Icon" icon="[object Object]">

View file

@ -1,7 +1,7 @@
// Vitest Snapshot v1
exports[`renders 1`] = `
<article data-v-9a89d9b9="" class="playing song-item group text-k-text-secondary border-b border-k-border !max-w-full h-[64px] flex items-center transition-[background-color,_box-shadow] ease-in-out duration-200 focus:rounded-md focus focus-within:rounded-md focus:ring-inset focus:ring-1 focus:!ring-k-accent focus-within:ring-inset focus-within:ring-1 focus-within:!ring-k-accent hover:bg-white/5 hover:ring-inset hover:ring-1 hover:ring-white/10 hover:rounded-md" data-testid="song-item" tabindex="0"><span data-v-9a89d9b9="" class="track-number"><i data-v-47e95701="" data-v-9a89d9b9="" class="relative flex gap-1 content-between w-[13px] aspect-square"><span data-v-47e95701=""></span><span data-v-47e95701=""></span><span data-v-47e95701=""></span></i></span><span data-v-9a89d9b9="" class="thumbnail leading-none"><button data-v-9a89d9b9="" style="background-image: url(undefined/resources/assets/img/covers/default.svg);" title="Pause" class="song-thumbnail w-[48px] aspect-square bg-cover relative rounded overflow-hidden active:scale-95"><img alt="Cover image" src="https://example.com/cover.jpg" class="w-full aspect-square object-cover" loading="lazy"><span class="absolute top-0 left-0 w-full h-full group-hover:bg-black/40 z-10"></span><span class="absolute flex opacity-0 items-center justify-center w-[24px] aspect-square rounded-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-k-highlight group-hover:opacity-100 duration-500 transition z-20"><br data-testid="Icon" icon="[object Object]" class="text-white"></span></button></span><span data-v-9a89d9b9="" class="title-artist flex flex-col gap-2 overflow-hidden"><span data-v-9a89d9b9="" class="title text-k-text-primary !flex gap-2 items-center"><!--v-if--> Test Song</span><span data-v-9a89d9b9="" class="artist">Test Artist</span></span><span data-v-9a89d9b9="" class="album">Test Album</span>
<article data-v-9a89d9b9="" class="playing song-item group text-k-text-secondary border-b border-k-border !max-w-full h-[64px] flex items-center transition-[background-color,_box-shadow] ease-in-out duration-200 focus:rounded-md focus focus-within:rounded-md focus:ring-inset focus:ring-1 focus:!ring-k-accent focus-within:ring-inset focus-within:ring-1 focus-within:!ring-k-accent hover:bg-white/5 hover:ring-inset hover:ring-1 hover:ring-white/10 hover:rounded-md" data-testid="song-item" tabindex="0"><span data-v-9a89d9b9="" class="track-number"><i data-v-47e95701="" data-v-9a89d9b9="" class="relative flex gap-1 content-between w-[13px] aspect-square"><span data-v-47e95701=""></span><span data-v-47e95701=""></span><span data-v-47e95701=""></span></i></span><span data-v-9a89d9b9="" class="thumbnail leading-none"><button data-v-9a89d9b9="" style="background-image: url(undefined/resources/assets/img/covers/default.svg);" title="Pause" class="song-thumbnail w-[48px] aspect-square bg-cover relative rounded overflow-hidden active:scale-95"><img alt="Cover image" src="https://example.com/cover.jpg" class="w-full aspect-square object-cover" loading="lazy"><span class="absolute top-0 left-0 w-full h-full group-hover:bg-black/40 no-hover:bg-black/40 z-10"></span><span class="absolute flex opacity-0 no-hover:opacity-100 items-center justify-center w-[24px] aspect-square rounded-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-k-highlight group-hover:opacity-100 duration-500 transition z-20"><br data-testid="Icon" icon="[object Object]" class="text-white"></span></button></span><span data-v-9a89d9b9="" class="title-artist flex flex-col gap-2 overflow-hidden"><span data-v-9a89d9b9="" class="title text-k-text-primary !flex gap-2 items-center"><!--v-if--> Test Song</span><span data-v-9a89d9b9="" class="artist">Test Artist</span></span><span data-v-9a89d9b9="" class="album">Test Album</span>
<!--v-if--><span data-v-9a89d9b9="" class="time">16:40</span><span data-v-9a89d9b9="" class="extra"><button data-v-9a89d9b9="" class="transition-[color] duration-200 ease-in-out text-k-text-secondary hover:text-k-text-primary" type="button" title="Unlike"><br data-testid="Icon" icon="[object Object]"></button></span>
</article>
`;

View file

@ -1,5 +1,5 @@
// Vitest Snapshot v1
exports[`renders for album 1`] = `<button data-v-40f79232="" class="thumbnail relative w-full aspect-square bg-no-repeat bg-cover bg-center overflow-hidden rounded-md active:scale-95" style="background-image: url(undefined/resources/assets/img/covers/default.svg);" data-testid="album-artist-thumbnail"><img data-v-40f79232="" alt="Thumbnail" src="https://test/album.jpg" class="w-full aspect-square object-cover" loading="lazy"><span data-v-40f79232="" class="hidden">Play all songs in the album IV</span><span data-v-40f79232="" class="absolute top-0 left-0 w-full h-full group-hover:bg-black/40 z-10"></span><span data-v-40f79232="" class="play-icon absolute flex opacity-0 items-center justify-center w-[32px] aspect-square rounded-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-k-highlight group-hover:opacity-100 duration-500 transition z-20"><br data-v-40f79232="" data-testid="Icon" icon="[object Object]" class="ml-1 text-white" size="lg"></span></button>`;
exports[`renders for album 1`] = `<button data-v-40f79232="" class="thumbnail relative w-full aspect-square bg-no-repeat bg-cover bg-center overflow-hidden rounded-md active:scale-95" style="background-image: url(undefined/resources/assets/img/covers/default.svg);" data-testid="album-artist-thumbnail"><img data-v-40f79232="" alt="Thumbnail" src="https://test/album.jpg" class="w-full aspect-square object-cover" loading="lazy"><span data-v-40f79232="" class="hidden">Play all songs in the album IV</span><span data-v-40f79232="" class="absolute top-0 left-0 w-full h-full group-hover:bg-black/40 no-hover:bg-black/40 z-10"></span><span data-v-40f79232="" class="play-icon absolute flex opacity-0 no-hover:opacity-100 items-center justify-center w-[32px] aspect-square rounded-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-k-highlight group-hover:opacity-100 duration-500 transition z-20"><br data-v-40f79232="" data-testid="Icon" icon="[object Object]" class="ml-0.5 text-white" size="lg"></span></button>`;
exports[`renders for artist 1`] = `<button data-v-40f79232="" class="thumbnail relative w-full aspect-square bg-no-repeat bg-cover bg-center overflow-hidden rounded-md active:scale-95" style="background-image: url(undefined/resources/assets/img/covers/default.svg);" data-testid="album-artist-thumbnail"><img data-v-40f79232="" alt="Thumbnail" src="https://test/blimp.jpg" class="w-full aspect-square object-cover" loading="lazy"><span data-v-40f79232="" class="hidden">Play all songs by Led Zeppelin</span><span data-v-40f79232="" class="absolute top-0 left-0 w-full h-full group-hover:bg-black/40 z-10"></span><span data-v-40f79232="" class="play-icon absolute flex opacity-0 items-center justify-center w-[32px] aspect-square rounded-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-k-highlight group-hover:opacity-100 duration-500 transition z-20"><br data-v-40f79232="" data-testid="Icon" icon="[object Object]" class="ml-1 text-white" size="lg"></span></button>`;
exports[`renders for artist 1`] = `<button data-v-40f79232="" class="thumbnail relative w-full aspect-square bg-no-repeat bg-cover bg-center overflow-hidden rounded-md active:scale-95" style="background-image: url(undefined/resources/assets/img/covers/default.svg);" data-testid="album-artist-thumbnail"><img data-v-40f79232="" alt="Thumbnail" src="https://test/blimp.jpg" class="w-full aspect-square object-cover" loading="lazy"><span data-v-40f79232="" class="hidden">Play all songs by Led Zeppelin</span><span data-v-40f79232="" class="absolute top-0 left-0 w-full h-full group-hover:bg-black/40 no-hover:bg-black/40 z-10"></span><span data-v-40f79232="" class="play-icon absolute flex opacity-0 no-hover:opacity-100 items-center justify-center w-[32px] aspect-square rounded-full top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-k-highlight group-hover:opacity-100 duration-500 transition z-20"><br data-v-40f79232="" data-testid="Icon" icon="[object Object]" class="ml-0.5 text-white" size="lg"></span></button>`;

View file

@ -42,7 +42,7 @@ export const useDraggable = (type: DraggableType) => {
case 'playables':
dragged = arrayify(<Playable>dragged)
text = dragged.length === 1
? `${dragged[0].title} by ${ getPlayableProp(dragged[0], 'artist_name', 'podcast_author')}`
? `${dragged[0].title} by ${getPlayableProp(dragged[0], 'artist_name', 'podcast_author')}`
: pluralize(dragged, 'item')
data = dragged.map(song => song.id)
@ -110,7 +110,7 @@ export const useDroppable = (acceptedTypes: DraggableType[]) => {
switch (getDragType(event)) {
case 'playlist':
const id = String(JSON.parse(event.dataTransfer!.getData('application/x-koel.playlist')))
return (playlistStore.byId(id)) as T | undefined
return playlistStore.byId(id) as T | undefined
default:
return
}

View file

@ -7,17 +7,17 @@ import { songStore } from '@/stores'
const UNKNOWN_ALBUM_ID = 1
export const albumStore = {
vault: new Map<number, UnwrapNestedRefs<Album>>(),
vault: new Map<Album['id'], Album>(),
state: reactive({
albums: [] as Album[]
}),
byId (id: number) {
byId (id: Album['id']) {
return this.vault.get(id)
},
removeByIds (ids: number[]) {
removeByIds (ids: Album['id'][]) {
this.state.albums = differenceBy(this.state.albums, ids.map(id => this.byId(id)), 'id')
ids.forEach(id => {
this.vault.delete(id)
@ -25,12 +25,12 @@ export const albumStore = {
})
},
isUnknown: (album: Album | number) => {
isUnknown: (album: Album | Album['id']) => {
if (typeof album === 'number') return album === UNKNOWN_ALBUM_ID
return album.id === UNKNOWN_ALBUM_ID
},
syncWithVault (albums: Album | Album[]) {
syncWithVault (albums: MaybeArray<Album>) {
return arrayify(albums).map(album => {
let local = this.vault.get(album.id)
local = reactive(local ? merge(local, album) : album)
@ -59,11 +59,11 @@ export const albumStore = {
/**
* Fetch the (blurry) thumbnail-sized version of an album's cover.
*/
fetchThumbnail: async (id: number) => {
fetchThumbnail: async (id: Album['id']) => {
return (await http.get<{ thumbnailUrl: string }>(`albums/${id}/thumbnail`)).thumbnailUrl
},
async resolve (id: number) {
async resolve (id: Album['id']) {
let album = this.byId(id)
if (!album) {
@ -86,7 +86,7 @@ export const albumStore = {
return resource.links.next ? ++resource.meta.current_page : null
},
async fetchForArtist (artist: Artist | number) {
async fetchForArtist (artist: Artist | Artist['id']) {
const id = typeof artist === 'number' ? artist : artist.id
return this.syncWithVault(

View file

@ -7,30 +7,30 @@ const UNKNOWN_ARTIST_ID = 1
const VARIOUS_ARTISTS_ID = 2
export const artistStore = {
vault: new Map<number, UnwrapNestedRefs<Artist>>(),
vault: new Map<Artist['id'], Artist>(),
state: reactive({
artists: [] as Artist[]
}),
byId (id: number) {
byId (id: Artist['id']) {
return this.vault.get(id)
},
removeByIds (ids: number[]) {
removeByIds (ids: Artist['id'][]) {
this.state.artists = differenceBy(this.state.artists, ids.map(id => this.byId(id)), 'id')
ids.forEach(id => this.vault.delete(id))
},
isVarious: (artist: Artist | number) => (typeof artist === 'number')
isVarious: (artist: Artist | Artist['id']) => (typeof artist === 'number')
? artist === VARIOUS_ARTISTS_ID
: artist.id === VARIOUS_ARTISTS_ID,
isUnknown: (artist: Artist | number) => (typeof artist === 'number')
isUnknown: (artist: Artist | Artist['id']) => (typeof artist === 'number')
? artist === UNKNOWN_ARTIST_ID
: artist.id === UNKNOWN_ARTIST_ID,
isStandard (artist: Artist | number) {
isStandard (artist: Artist | Artist['id']) {
return !this.isVarious(artist) && !this.isUnknown(artist)
},
@ -43,7 +43,7 @@ export const artistStore = {
return artist.image
},
syncWithVault (artists: Artist | Artist[]) {
syncWithVault (artists: MaybeArray<Artist>) {
return arrayify(artists).map(artist => {
let local = this.vault.get(artist.id)
local = local ? Object.assign(local, artist) : reactive(artist)
@ -53,7 +53,7 @@ export const artistStore = {
})
},
async resolve (id: number) {
async resolve (id: Artist['id']) {
let artist = this.byId(id)
if (!artist) {

View file

@ -30,7 +30,7 @@ const initialState = {
song_length: 0,
queue_state: {
type: 'queue-states',
playables: [],
songs: [],
current_song: null,
playback_position: 0
} as QueueState

View file

@ -12,7 +12,7 @@ export const playlistFolderStore = {
this.state.folders = this.sort(reactive(folders))
},
byId (id: string) {
byId (id: PlaylistFolder['id']) {
return this.state.folders.find(folder => folder.id === id)
},

View file

@ -53,7 +53,7 @@ export const playlistStore = {
})
},
byId (id: string) {
byId (id: Playlist['id']) {
return this.state.playlists.find(playlist => playlist.id === id)
},

View file

@ -6,11 +6,11 @@ export const podcastStore = {
podcasts: [] as Podcast[]
}),
byId (id: string) {
byId (id: Podcast['id']) {
return this.state.podcasts.find(podcast => podcast.id === id)
},
async resolve (id: string) {
async resolve (id: Podcast['id']) {
return this.byId(id) ?? await this.fetchOne(id)
},
@ -26,7 +26,7 @@ export const podcastStore = {
return this.state.podcasts
},
async fetchOne (id: string) {
async fetchOne (id: Podcast['id']) {
this.state.podcasts.push(await http.get<Podcast>(`podcasts/${id}`))
return this.byId(id)!
},

View file

@ -62,7 +62,7 @@ const preferenceStore = {
}
},
get (key: string) {
get (key: keyof UserPreferences) {
return this.state?.[key]
},

View file

@ -51,15 +51,15 @@ export const songStore = {
getFormattedLength: (playables: MaybeArray<Playable>) => secondsToHumanReadable(sumBy(arrayify(playables), 'length')),
byId (id: string) {
const song = this.vault.get(id)
byId (id: Playable['id']) {
const playable = this.vault.get(id)
if (!song) return
if (isSong(song) && song.deleted) return
return song
if (!playable) return
if (isSong(playable) && playable.deleted) return
return playable
},
byIds (ids: string[]) {
byIds (ids: Playable['id'][]) {
const playables: Playable[] = []
ids.forEach(id => use(this.byId(id), song => playables.push(song!)))
return playables
@ -70,7 +70,7 @@ export const songStore = {
.filter(playable => isSong(playable) && playable.album_id === album.id) as Song[]
},
async resolve (id: string) {
async resolve (id: Playable['id']) {
let playable = this.byId(id)
if (!playable) {
@ -172,7 +172,7 @@ export const songStore = {
ensureNotDeleted: (songs: MaybeArray<Song>) => arrayify(songs).filter(({ deleted }) => !deleted),
async fetchForAlbum (album: Album | number) {
async fetchForAlbum (album: Album | Album['id']) {
const id = typeof album === 'number' ? album : album.id
return this.ensureNotDeleted(await cache.remember<Song[]>(
@ -181,7 +181,7 @@ export const songStore = {
))
},
async fetchForArtist (artist: Artist | number) {
async fetchForArtist (artist: Artist | Artist['id']) {
const id = typeof artist === 'number' ? artist : artist.id
return this.ensureNotDeleted(await cache.remember<Song[]>(
@ -217,7 +217,7 @@ export const songStore = {
return uniqBy(playables, 'id')
},
async fetchForPodcast (podcast: Podcast | string, refresh = false) {
async fetchForPodcast (podcast: Podcast | Podcast['id'], refresh = false) {
const id = typeof podcast === 'string' ? podcast : podcast.id
if (refresh) {

View file

@ -44,11 +44,11 @@ export const themeStore = {
return this.state.themes.find(theme => theme.id === id)
},
getDefaultTheme (): Theme {
getDefaultTheme () {
return this.getThemeById('classic')!
},
applyThemeFromPreference (): void {
applyThemeFromPreference () {
const theme = preferences.theme
? (this.getThemeById(preferences.theme) ?? this.getDefaultTheme())
: this.getDefaultTheme()

View file

@ -18,14 +18,14 @@ export interface UpdateUserData extends UserFormData {
}
export const userStore = {
vault: new Map<number, User>(),
vault: new Map<User['id'], User>(),
state: reactive({
users: [] as User[],
current: null as unknown as User
}),
syncWithVault (users: User | User[]) {
syncWithVault (users: MaybeArray<User>) {
return arrayify(users).map(user => {
let local = this.byId(user.id)
local = reactive(local ? merge(local, user) : user)
@ -44,7 +44,7 @@ export const userStore = {
this.state.users = this.syncWithVault(await http.get<User[]>('users'))
},
byId (id: number) {
byId (id: User['id']) {
return this.vault.get(id)
},
@ -58,7 +58,7 @@ export const userStore = {
return this.byId(user.id)
},
add (user: User | User[]) {
add (user: MaybeArray<User>) {
this.state.users.push(...this.syncWithVault(user))
},