mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
add usePlayer hook
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { createContext, useCallback, useMemo } from 'react';
|
import { createContext, useCallback, useContext, useMemo } from 'react';
|
||||||
|
|
||||||
import { AddToQueueType, usePlayerActions } from '/@/renderer/store';
|
import { AddToQueueType, usePlayerActions } from '/@/renderer/store';
|
||||||
import { LibraryItem, QueueSong, Song } from '/@/shared/types/domain-types';
|
import { LibraryItem, QueueSong, Song } from '/@/shared/types/domain-types';
|
||||||
@@ -75,6 +75,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
(id: string[], itemType: LibraryItem, type: AddToQueueType) => {},
|
(id: string[], itemType: LibraryItem, type: AddToQueueType) => {},
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
const clearQueue = useCallback(() => {
|
const clearQueue = useCallback(() => {
|
||||||
storeActions.clearQueue();
|
storeActions.clearQueue();
|
||||||
}, [storeActions]);
|
}, [storeActions]);
|
||||||
@@ -247,3 +248,7 @@ export const PlayerProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
|
|
||||||
return <PlayerContext.Provider value={contextValue}>{children}</PlayerContext.Provider>;
|
return <PlayerContext.Provider value={contextValue}>{children}</PlayerContext.Provider>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const usePlayer = () => {
|
||||||
|
return useContext(PlayerContext);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user