Reset music state whenever new credentials are set

This commit is contained in:
Lei Nelissen
2020-07-07 15:44:22 +02:00
parent 7ffb38b7f6
commit 91f4f349b9

View File

@@ -1,6 +1,7 @@
import { fetchAllAlbums, albumAdapter, fetchTracksByAlbum, trackAdapter, fetchRecentAlbums } from './actions';
import { createSlice, Dictionary, EntityId } from '@reduxjs/toolkit';
import { Album, AlbumTrack } from './types';
import { setJellyfinCredentials } from 'store/settings/actions';
export interface State {
albums: {
@@ -69,6 +70,9 @@ const music = createSlice({
});
builder.addCase(fetchTracksByAlbum.pending, (state) => { state.tracks.isLoading = true; });
builder.addCase(fetchTracksByAlbum.rejected, (state) => { state.tracks.isLoading = false; });
// Reset any caches we have when a new server is set
builder.addCase(setJellyfinCredentials, () => initialState);
}
});