vroom-react
Version:
Vroom React UI
17 lines (14 loc) • 508 B
text/typescript
const publisherAudioReducer = (state: string, action: { type: string, payload: any}) => {
let tmp
switch (action.type) {
case 'add':
tmp = state.split(',').filter((i: any) => i !== `${action.payload.id}` && i !== '')
tmp[tmp.length] = `${action.payload.id}`
return tmp.join(',')
case 'remove':
return state.split(',').filter((i: any) => i !== `${action.payload.id}` && i !== '').join(',')
default:
return state || ''
}
}
export default publisherAudioReducer