2020-05-25 20:50:46 +02:00
|
|
|
const ADD_TO_PLAYLIST_OPEN = 'ADD_TO_PLAYLIST_OPEN'
|
|
|
|
const ADD_TO_PLAYLIST_CLOSE = 'ADD_TO_PLAYLIST_CLOSE'
|
2020-05-24 06:03:42 +02:00
|
|
|
|
2020-05-25 20:50:46 +02:00
|
|
|
const openAddToPlaylist = ({ albumId, selectedIds, onSuccess }) => ({
|
|
|
|
type: ADD_TO_PLAYLIST_OPEN,
|
2020-05-24 06:03:42 +02:00
|
|
|
albumId,
|
|
|
|
selectedIds,
|
2020-05-25 20:50:46 +02:00
|
|
|
onSuccess,
|
2020-05-24 06:03:42 +02:00
|
|
|
})
|
|
|
|
|
2020-05-25 20:50:46 +02:00
|
|
|
const closeAddToPlaylist = () => ({
|
|
|
|
type: ADD_TO_PLAYLIST_CLOSE,
|
2020-05-24 06:03:42 +02:00
|
|
|
})
|
|
|
|
|
2020-05-25 20:50:46 +02:00
|
|
|
const addToPlaylistDialogReducer = (
|
2020-05-24 06:03:42 +02:00
|
|
|
previousState = {
|
|
|
|
open: false,
|
|
|
|
},
|
|
|
|
payload
|
|
|
|
) => {
|
|
|
|
const { type } = payload
|
|
|
|
switch (type) {
|
2020-05-25 20:50:46 +02:00
|
|
|
case ADD_TO_PLAYLIST_OPEN:
|
2020-05-24 06:03:42 +02:00
|
|
|
return {
|
|
|
|
...previousState,
|
|
|
|
open: true,
|
|
|
|
albumId: payload.albumId,
|
|
|
|
selectedIds: payload.selectedIds,
|
2020-05-25 20:50:46 +02:00
|
|
|
onSuccess: payload.onSuccess,
|
2020-05-24 06:03:42 +02:00
|
|
|
}
|
2020-05-25 20:50:46 +02:00
|
|
|
case ADD_TO_PLAYLIST_CLOSE:
|
|
|
|
return { ...previousState, open: false, onSuccess: undefined }
|
2020-05-24 06:03:42 +02:00
|
|
|
default:
|
|
|
|
return previousState
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-25 20:50:46 +02:00
|
|
|
export { openAddToPlaylist, closeAddToPlaylist, addToPlaylistDialogReducer }
|