mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com> Co-authored-by: Selis <selis@xynolabs.com>
51 lines
839 B
JavaScript
51 lines
839 B
JavaScript
/**
|
|
* @file
|
|
* @copyright 2020 Aleksej Komarov
|
|
* @license MIT
|
|
*/
|
|
|
|
const initialState = {
|
|
visible: false,
|
|
playing: false,
|
|
track: null,
|
|
};
|
|
|
|
export const audioReducer = (state = initialState, action) => {
|
|
const { type, payload } = action;
|
|
if (type === 'audio/playing') {
|
|
return {
|
|
...state,
|
|
visible: true,
|
|
playing: true,
|
|
};
|
|
}
|
|
if (type === 'audio/stopped') {
|
|
return {
|
|
...state,
|
|
visible: false,
|
|
playing: false,
|
|
};
|
|
}
|
|
if (type === 'audio/playMusic') {
|
|
return {
|
|
...state,
|
|
meta: payload,
|
|
};
|
|
}
|
|
if (type === 'audio/stopMusic') {
|
|
return {
|
|
...state,
|
|
visible: false,
|
|
playing: false,
|
|
meta: null,
|
|
};
|
|
}
|
|
if (type === 'audio/toggle') {
|
|
return {
|
|
...state,
|
|
visible: !state.visible,
|
|
};
|
|
}
|
|
return state;
|
|
};
|