Skip to content

Commit a5ffc55

Browse files
optimize the solution
1 parent 2e37b38 commit a5ffc55

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/renderer/components/AlbumArt.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default function AlbumArt({
2424
(store) => store.currentSongMetadata,
2525
);
2626
const currentSongDataURL = usePlayerStore(
27-
(store) => store.currentSongDataURL,
27+
(store) => store.currentSongArtworkDataURL,
2828
);
2929
const filteredLibrary = usePlayerStore((store) => store.filteredLibrary);
3030
const setOverrideScrollToIndex = usePlayerStore(

src/renderer/components/Browser.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export default function Browser({ onClose }: BrowserProps) {
233233
selectedItem: string | null,
234234
onClick: (item: string | null) => void,
235235
) =>
236-
// eslint-disable-next-line react/no-unstable-nested-components
236+
// eslint-disable-next-line react/no-unstable-nested-components, func-names
237237
function ({
238238
index,
239239
key,

src/renderer/components/Main.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default function Main() {
5959
(store) => store.setOverrideScrollToIndex,
6060
);
6161
const setCurrentSongWithDetails = usePlayerStore(
62-
(store) => store.setCurrentSongWithDetails,
62+
(store) => store.setCurrentSong,
6363
);
6464

6565
/**

src/renderer/store/player.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ interface PlayerStore {
77
* state
88
*/
99
paused: boolean;
10-
currentSong: string;
11-
currentSongDataURL: string;
12-
currentSongMetadata: LightweightAudioMetadata;
10+
currentSong: string; // holds the path of the current song
11+
currentSongArtworkDataURL: string; // holds the artwork of the current song
12+
currentSongMetadata: LightweightAudioMetadata; // holds the metadata of the current song
1313
shuffle: boolean;
1414
repeating: boolean;
1515
volume: number;
@@ -26,7 +26,7 @@ interface PlayerStore {
2626
setPaused: (paused: boolean) => void;
2727
setShuffle: (shuffle: boolean) => void;
2828
setRepeating: (repeating: boolean) => void;
29-
setCurrentSongWithDetails: (
29+
setCurrentSong: (
3030
songPath: string,
3131
library?: { [key: string]: LightweightAudioMetadata },
3232
) => void;
@@ -44,7 +44,7 @@ const usePlayerStore = create<PlayerStore>((set) => ({
4444
*/
4545
paused: true,
4646
currentSong: '',
47-
currentSongDataURL: '',
47+
currentSongArtworkDataURL: '',
4848
currentSongMetadata: {} as LightweightAudioMetadata,
4949
shuffle: false,
5050
repeating: false,
@@ -73,7 +73,7 @@ const usePlayerStore = create<PlayerStore>((set) => ({
7373
// @note: when shuffle is toggled on or off we clear the shuffle history
7474
setShuffle: (shuffle) => set({ shuffle, shuffleHistory: [] }),
7575
setRepeating: (repeating) => set({ repeating }),
76-
setCurrentSongWithDetails: (songPath: string, library) => {
76+
setCurrentSong: (songPath: string, library) => {
7777
if (!library) {
7878
// eslint-disable-next-line no-console
7979
console.error('No library provided to setCurrentSongWithDetails');
@@ -110,7 +110,7 @@ const usePlayerStore = create<PlayerStore>((set) => ({
110110
url = await bufferToDataUrl(event.data, event.format);
111111
}
112112

113-
set({ currentSongDataURL: url });
113+
set({ currentSongArtworkDataURL: url });
114114

115115
if (navigator.mediaSession.metadata?.artwork) {
116116
navigator.mediaSession.metadata.artwork = [

0 commit comments

Comments
 (0)