mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-16 21:50:35 +02:00
21 lines
618 B
TypeScript
21 lines
618 B
TypeScript
import { useMemo } from 'react';
|
|
|
|
import { usePlayerSong } from '/@/renderer/store';
|
|
import { QueueSong, Song } from '/@/shared/types/domain-types';
|
|
|
|
export const useIsCurrentSong = (song: QueueSong | Song) => {
|
|
const currentSong = usePlayerSong();
|
|
|
|
const isActive = useMemo(() => {
|
|
const queueSong = song as QueueSong;
|
|
|
|
if (queueSong._uniqueId != null && queueSong._uniqueId !== '') {
|
|
return queueSong._uniqueId === currentSong?._uniqueId;
|
|
}
|
|
|
|
return song.id === currentSong?.id;
|
|
}, [song, currentSong?.id, currentSong?._uniqueId]);
|
|
|
|
return { isActive };
|
|
};
|