1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 21:06:42 +07:00

refactored playerbar component

This commit is contained in:
Fedor Katurov 2021-11-21 17:31:50 +07:00
parent 6ca4c514bf
commit df217b41f7
9 changed files with 78 additions and 53 deletions

View file

@ -0,0 +1,17 @@
import { useShallowSelect } from '~/utils/hooks/useShallowSelect';
import { selectPlayer } from '~/redux/player/selectors';
import { useCallback } from 'react';
import { playerPause, playerPlay, playerSeek, playerStop } from '~/redux/player/actions';
import { useDispatch } from 'react-redux';
export const usePlayer = () => {
const { status, file } = useShallowSelect(selectPlayer);
const dispatch = useDispatch();
const onPlayerPlay = useCallback(() => dispatch(playerPlay()), [dispatch]);
const onPlayerPause = useCallback(() => dispatch(playerPause()), [dispatch]);
const onPlayerSeek = useCallback((pos: number) => dispatch(playerSeek(pos)), [dispatch]);
const onPlayerStop = useCallback(() => dispatch(playerStop()), [dispatch]);
return { status, file, onPlayerPlay, onPlayerSeek, onPlayerPause, onPlayerStop };
};