瀏覽代碼

fix: deselect album when searching for artists

Fela Maslen 5 年之前
父節點
當前提交
ff7c3e4082

+ 4 - 2
gmus-web/src/components/ui/cmus/reducer/search.spec.ts

@@ -23,7 +23,8 @@ describe('Searching', () => {
       artists: ['Amy Winehouse', 'Anticon', 'Bach'],
       library: {
         ...stateSearching.library,
-        activeArtist: null,
+        activeArtist: 'Amy Winehouse',
+        activeAlbum: 'Back to Black',
         modeWindow: LibraryModeWindow.ArtistList,
         activeSongId: 883,
       },
@@ -49,10 +50,11 @@ describe('Searching', () => {
 
     describe('artists', () => {
       it('should select the first match', () => {
-        expect.assertions(2);
+        expect.assertions(3);
         const result = cmusUIReducer(stateSearchingArtists, searched('ant'));
         expect(result.library.activeArtist).toBe('Anticon');
         expect(result.library.activeSongId).toBeNull();
+        expect(result.library.activeAlbum).toBeNull();
       });
 
       describe('when the artist has songs loaded', () => {

+ 4 - 1
gmus-web/src/components/ui/cmus/reducer/search.ts

@@ -9,7 +9,10 @@ function searchForArtist(state: CmusUIState, term: string): CmusUIState {
 
   const activeSongId = state.artistSongs[closestArtist]?.[0]?.id ?? null;
 
-  return { ...state, library: { ...state.library, activeArtist: closestArtist, activeSongId } };
+  return {
+    ...state,
+    library: { ...state.library, activeArtist: closestArtist, activeAlbum: null, activeSongId },
+  };
 }
 
 function searchForSong(state: CmusUIState, term: string): CmusUIState {