diff --git a/resources/assets/js/stores/albumStore.ts b/resources/assets/js/stores/albumStore.ts index 0542f5df..19dfe459 100644 --- a/resources/assets/js/stores/albumStore.ts +++ b/resources/assets/js/stores/albumStore.ts @@ -80,7 +80,7 @@ export const albumStore = { }, async paginate (page: number) { - const resource = await http.get(`albums?page=${page}`) + const resource = await http.get>(`albums?page=${page}`) this.state.albums = unionBy(this.state.albums, this.syncWithVault(resource.data), 'id') return resource.links.next ? ++resource.meta.current_page : null diff --git a/resources/assets/js/stores/artistStore.ts b/resources/assets/js/stores/artistStore.ts index 90a48c12..0db657dc 100644 --- a/resources/assets/js/stores/artistStore.ts +++ b/resources/assets/js/stores/artistStore.ts @@ -70,7 +70,7 @@ export const artistStore = { }, async paginate (page: number) { - const resource = await http.get(`artists?page=${page}`) + const resource = await http.get>(`artists?page=${page}`) this.state.artists = unionBy(this.state.artists, this.syncWithVault(resource.data), 'id') return resource.links.next ? ++resource.meta.current_page : null diff --git a/resources/assets/js/stores/songStore.ts b/resources/assets/js/stores/songStore.ts index cf062b33..05ea0e11 100644 --- a/resources/assets/js/stores/songStore.ts +++ b/resources/assets/js/stores/songStore.ts @@ -66,7 +66,8 @@ export const songStore = { }, byAlbum (album: Album) { - return Array.from(this.vault.values()).filter(playable => isSong(playable) && playable.album_id === album.id) + return Array.from(this.vault.values()) + .filter(playable => isSong(playable) && playable.album_id === album.id) as Song[] }, async resolve (id: string) { @@ -231,7 +232,11 @@ export const songStore = { async paginateForGenre (genre: Genre | Genre['name'], params: GenreSongListPaginateParams) { const name = typeof genre === 'string' ? genre : genre.name - const resource = await http.get(`genres/${name}/songs?${new URLSearchParams(params).toString()}`) + + const resource = await http.get>( + `genres/${name}/songs?${new URLSearchParams(params).toString()}` + ) + const songs = this.syncWithVault(resource.data) return { @@ -246,7 +251,7 @@ export const songStore = { }, async paginate (params: SongListPaginateParams) { - const resource = await http.get(`songs?${new URLSearchParams(params).toString()}`) + const resource = await http.get>(`songs?${new URLSearchParams(params).toString()}`) this.state.songs = unionBy(this.state.songs, this.syncWithVault(resource.data), 'id') return resource.links.next ? ++resource.meta.current_page : null diff --git a/resources/assets/js/types.d.ts b/resources/assets/js/types.d.ts index eae41efd..96e04b19 100644 --- a/resources/assets/js/types.d.ts +++ b/resources/assets/js/types.d.ts @@ -479,8 +479,8 @@ type MoveType = 'before' | 'after' type MethodOf = { [K in keyof T]: T[K] extends Closure ? K : never; }[keyof T] -interface PaginatorResource { - data: any[] +interface PaginatorResource { + data: T[] links: { next: string | null }