feat: add extra metadata to the album view
This commit is contained in:
@@ -46,6 +46,14 @@ export const fetchTracksByAlbum = createAsyncThunk<AlbumTrack[], string, AsyncTh
|
||||
}
|
||||
);
|
||||
|
||||
export const fetchAlbum = createAsyncThunk<Album, string, AsyncThunkAPI>(
|
||||
'/albums/single',
|
||||
async (ItemId, thunkAPI) => {
|
||||
const credentials = thunkAPI.getState().settings.jellyfin;
|
||||
return retrieveAlbum(credentials, ItemId) as Promise<Album>;
|
||||
}
|
||||
);
|
||||
|
||||
type SearchAndFetchResults = {
|
||||
albums: Album[];
|
||||
results: (Album | AlbumTrack)[];
|
||||
|
||||
@@ -7,7 +7,8 @@ import {
|
||||
searchAndFetchAlbums,
|
||||
playlistAdapter,
|
||||
fetchAllPlaylists,
|
||||
fetchTracksByPlaylist
|
||||
fetchTracksByPlaylist,
|
||||
fetchAlbum
|
||||
} from './actions';
|
||||
import { createSlice, Dictionary, EntityId } from '@reduxjs/toolkit';
|
||||
import { Album, AlbumTrack, Playlist } from './types';
|
||||
@@ -69,6 +70,15 @@ const music = createSlice({
|
||||
});
|
||||
builder.addCase(fetchAllAlbums.pending, (state) => { state.albums.isLoading = true; });
|
||||
builder.addCase(fetchAllAlbums.rejected, (state) => { state.albums.isLoading = false; });
|
||||
|
||||
/**
|
||||
* Fetch single album
|
||||
*/
|
||||
builder.addCase(fetchAlbum.fulfilled, (state, { payload }) => {
|
||||
albumAdapter.upsertOne(state.albums, payload);
|
||||
});
|
||||
builder.addCase(fetchAlbum.pending, (state) => { state.albums.isLoading = true; });
|
||||
builder.addCase(fetchAlbum.rejected, (state) => { state.albums.isLoading = false; });
|
||||
|
||||
/**
|
||||
* Fetch most recent albums
|
||||
|
||||
@@ -43,6 +43,8 @@ export interface Album {
|
||||
Tracks?: string[];
|
||||
lastRefreshed?: number;
|
||||
DateCreated: string;
|
||||
Overview?: string;
|
||||
Similar?: string[];
|
||||
}
|
||||
|
||||
export interface AlbumTrack {
|
||||
@@ -94,4 +96,8 @@ export interface Playlist {
|
||||
MediaType: string;
|
||||
Tracks?: string[];
|
||||
lastRefreshed?: number;
|
||||
}
|
||||
|
||||
export interface SimilarAlbum {
|
||||
Id: string;
|
||||
}
|
||||
Reference in New Issue
Block a user