mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
handle player stop on queue clear
This commit is contained in:
@@ -2538,6 +2538,21 @@ export const subscribePlayerShuffle = (
|
||||
);
|
||||
};
|
||||
|
||||
export const subscribeQueueCleared = (onChange: () => void) => {
|
||||
return usePlayerStoreBase.subscribe(
|
||||
(state) => state.queue,
|
||||
(queue, prevQueue) => {
|
||||
// Detect if queue became empty
|
||||
const wasNotEmpty = prevQueue.default.length > 0 || prevQueue.priority.length > 0;
|
||||
const isEmpty = queue.default.length === 0 && queue.priority.length === 0;
|
||||
|
||||
if (wasNotEmpty && isEmpty) {
|
||||
onChange();
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
export const usePlayerProperties = () => {
|
||||
return usePlayerStoreBase(
|
||||
useShallow((state) => ({
|
||||
|
||||
Reference in New Issue
Block a user