File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -104,16 +104,14 @@ export default function Browser({ onClose }: BrowserProps) {
104
104
useEffect ( ( ) => {
105
105
if ( ! storeLibrary ) return ;
106
106
107
- const filteredSongs = { ...storeLibrary } ;
108
- Object . keys ( filteredSongs ) . forEach ( ( key ) => {
109
- const song = filteredSongs [ key ] ;
110
- if (
111
- ( selection . artist && song . common . artist !== selection . artist ) ||
112
- ( selection . album && song . common . album !== selection . album )
113
- ) {
114
- delete filteredSongs [ key ] ;
115
- }
116
- } ) ;
107
+ const filteredSongs = Object . fromEntries (
108
+ Object . entries ( storeLibrary ) . filter ( ( [ _ , song ] ) => {
109
+ return (
110
+ ( ! selection . artist || song . common . artist === selection . artist ) &&
111
+ ( ! selection . album || song . common . album === selection . album )
112
+ ) ;
113
+ } ) ,
114
+ ) ;
117
115
118
116
setFilteredLibrary ( filteredSongs ) ;
119
117
} , [ selection , storeLibrary , setFilteredLibrary ] ) ;
You can’t perform that action at this time.
0 commit comments