* Refactor session_keys to its own package * Adjust play_tracker - Don't send external NowPlaying/Scrobble for tracks with unknown artist - Continue to the next agent on error * Implement ListenBrainz Agent and Auth Router * Implement frontend for ListenBrainz linking * Update listenBrainzRequest - Don't marshal Player to json - Rename Track to Title * Return ErrRetryLater on ListenBrainz server errors * Add tests for listenBrainzAgent * Add tests for ListenBrainz Client * Adjust ListenBrainzTokenDialog to handle errors better * Refactor listenbrainz.formatListen and listenBrainzRequest structs * Refactor agent auth_routers * Refactor session_keys to agents package * Add test for listenBrainzResponse * Add tests for ListenBrainz auth_router * Update ListenBrainzTokenDialog and auth_router * Adjust player scrobble toggle
88 lines
1.8 KiB
JavaScript
88 lines
1.8 KiB
JavaScript
import {
|
|
ADD_TO_PLAYLIST_CLOSE,
|
|
ADD_TO_PLAYLIST_OPEN,
|
|
DUPLICATE_SONG_WARNING_OPEN,
|
|
DUPLICATE_SONG_WARNING_CLOSE,
|
|
EXTENDED_INFO_OPEN,
|
|
EXTENDED_INFO_CLOSE,
|
|
LISTENBRAINZ_TOKEN_OPEN,
|
|
LISTENBRAINZ_TOKEN_CLOSE,
|
|
} from '../actions'
|
|
|
|
export const addToPlaylistDialogReducer = (
|
|
previousState = {
|
|
open: false,
|
|
duplicateSong: false,
|
|
},
|
|
payload
|
|
) => {
|
|
const { type } = payload
|
|
switch (type) {
|
|
case ADD_TO_PLAYLIST_OPEN:
|
|
return {
|
|
...previousState,
|
|
open: true,
|
|
selectedIds: payload.selectedIds,
|
|
onSuccess: payload.onSuccess,
|
|
}
|
|
case ADD_TO_PLAYLIST_CLOSE:
|
|
return { ...previousState, open: false, onSuccess: undefined }
|
|
case DUPLICATE_SONG_WARNING_OPEN:
|
|
return {
|
|
...previousState,
|
|
duplicateSong: true,
|
|
duplicateIds: payload.duplicateIds,
|
|
}
|
|
case DUPLICATE_SONG_WARNING_CLOSE:
|
|
return { ...previousState, duplicateSong: false }
|
|
default:
|
|
return previousState
|
|
}
|
|
}
|
|
|
|
export const expandInfoDialogReducer = (
|
|
previousState = {
|
|
open: false,
|
|
},
|
|
payload
|
|
) => {
|
|
const { type } = payload
|
|
switch (type) {
|
|
case EXTENDED_INFO_OPEN:
|
|
return {
|
|
...previousState,
|
|
open: true,
|
|
record: payload.record,
|
|
}
|
|
case EXTENDED_INFO_CLOSE:
|
|
return {
|
|
...previousState,
|
|
open: false,
|
|
}
|
|
default:
|
|
return previousState
|
|
}
|
|
}
|
|
|
|
export const listenBrainzTokenDialogReducer = (
|
|
previousState = {
|
|
open: false,
|
|
},
|
|
payload
|
|
) => {
|
|
const { type } = payload
|
|
switch (type) {
|
|
case LISTENBRAINZ_TOKEN_OPEN:
|
|
return {
|
|
...previousState,
|
|
open: true,
|
|
}
|
|
case LISTENBRAINZ_TOKEN_CLOSE:
|
|
return {
|
|
...previousState,
|
|
open: false,
|
|
}
|
|
default:
|
|
return previousState
|
|
}
|
|
}
|