From 91f4f349b91d8a37ddd09d0e16dccf8657d03749 Mon Sep 17 00:00:00 2001 From: Lei Nelissen Date: Tue, 7 Jul 2020 15:44:22 +0200 Subject: [PATCH] Reset music state whenever new credentials are set --- src/store/music/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/store/music/index.ts b/src/store/music/index.ts index 3b7a17a..c0a026f 100644 --- a/src/store/music/index.ts +++ b/src/store/music/index.ts @@ -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); } });