Files
CHOMPStation2/tgui/packages/tgui-panel/audio/reducer.js
CHOMPStation2 eb65b5721c [MIRROR] tgchat part 1 (#7273)
Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com>
Co-authored-by: Selis <selis@xynolabs.com>
2023-11-25 13:36:55 +01:00

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;
};