1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +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

@ -16,8 +16,8 @@ export const PLAYER_ACTIONS = {
GET_YOUTUBE_INFO: `${prefix}GET_YOUTUBE_INFO`,
};
export const PLAYER_STATES = {
PLAYING: 'PLAYING',
PAUSED: 'PAUSED',
UNSET: 'UNSET',
};
export enum PlayerState {
PLAYING = 'PLAYING',
PAUSED = 'PAUSED',
UNSET = 'UNSET',
}

View file

@ -1,16 +1,16 @@
import { createReducer } from '~/utils/reducer';
import { PLAYER_HANDLERS } from './handlers';
import { PLAYER_STATES } from './constants';
import { IFile, IEmbed } from '../types';
import { PlayerState } from './constants';
import { IEmbed, IFile } from '../types';
export type IPlayerState = Readonly<{
status: typeof PLAYER_STATES[keyof typeof PLAYER_STATES];
status: PlayerState;
file?: IFile;
youtubes: Record<string, IEmbed>;
}>;
const INITIAL_STATE: IPlayerState = {
status: PLAYER_STATES.UNSET,
status: PlayerState.UNSET,
file: undefined,
youtubes: {},
};

View file

@ -1,11 +1,11 @@
import { takeLatest, put, fork, race, take, delay, call, select } from 'redux-saga/effects';
import { PLAYER_ACTIONS, PLAYER_STATES } from './constants';
import { call, delay, fork, put, race, select, take, takeLatest } from 'redux-saga/effects';
import { PLAYER_ACTIONS, PlayerState } from './constants';
import {
playerSetFile,
playerSeek,
playerSetStatus,
playerGetYoutubeInfo,
playerSeek,
playerSet,
playerSetFile,
playerSetStatus,
} from './actions';
import { Player } from '~/utils/player';
import { getURL } from '~/utils/dom';
@ -41,7 +41,7 @@ function seekSaga({ seek }: ReturnType<typeof playerSeek>) {
}
function* stoppedSaga() {
yield put(playerSetStatus(PLAYER_STATES.UNSET));
yield put(playerSetStatus(PlayerState.UNSET));
yield put(playerSetFile(undefined));
}