mirror of
https://github.com/navidrome/navidrome.git
synced 2025-04-13 18:57:18 +03:00
fix(ui): save play mode for player (#3315)
* fix(ui): save play mode for player - 3019 * redux * redux
This commit is contained in:
parent
10a1b5faf8
commit
782cd26b3d
@ -6,6 +6,7 @@ export const PLAYER_CLEAR_QUEUE = 'PLAYER_CLEAR_QUEUE'
|
|||||||
export const PLAYER_PLAY_TRACKS = 'PLAYER_PLAY_TRACKS'
|
export const PLAYER_PLAY_TRACKS = 'PLAYER_PLAY_TRACKS'
|
||||||
export const PLAYER_CURRENT = 'PLAYER_CURRENT'
|
export const PLAYER_CURRENT = 'PLAYER_CURRENT'
|
||||||
export const PLAYER_SET_VOLUME = 'PLAYER_SET_VOLUME'
|
export const PLAYER_SET_VOLUME = 'PLAYER_SET_VOLUME'
|
||||||
|
export const PLAYER_SET_MODE = 'PLAYER_SET_MODE'
|
||||||
|
|
||||||
export const setTrack = (data) => ({
|
export const setTrack = (data) => ({
|
||||||
type: PLAYER_SET_TRACK,
|
type: PLAYER_SET_TRACK,
|
||||||
@ -89,3 +90,8 @@ export const setVolume = (volume) => ({
|
|||||||
type: PLAYER_SET_VOLUME,
|
type: PLAYER_SET_VOLUME,
|
||||||
data: { volume },
|
data: { volume },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const setPlayMode = (mode) => ({
|
||||||
|
type: PLAYER_SET_MODE,
|
||||||
|
data: { mode },
|
||||||
|
})
|
||||||
|
@ -16,7 +16,13 @@ import useCurrentTheme from '../themes/useCurrentTheme'
|
|||||||
import config from '../config'
|
import config from '../config'
|
||||||
import useStyle from './styles'
|
import useStyle from './styles'
|
||||||
import AudioTitle from './AudioTitle'
|
import AudioTitle from './AudioTitle'
|
||||||
import { clearQueue, currentPlaying, setVolume, syncQueue } from '../actions'
|
import {
|
||||||
|
clearQueue,
|
||||||
|
currentPlaying,
|
||||||
|
setPlayMode,
|
||||||
|
setVolume,
|
||||||
|
syncQueue,
|
||||||
|
} from '../actions'
|
||||||
import PlayerToolbar from './PlayerToolbar'
|
import PlayerToolbar from './PlayerToolbar'
|
||||||
import { sendNotification } from '../utils'
|
import { sendNotification } from '../utils'
|
||||||
import subsonic from '../subsonic'
|
import subsonic from '../subsonic'
|
||||||
@ -93,6 +99,7 @@ const Player = () => {
|
|||||||
() => ({
|
() => ({
|
||||||
theme: playerTheme,
|
theme: playerTheme,
|
||||||
bounds: 'body',
|
bounds: 'body',
|
||||||
|
playMode: playerState.mode,
|
||||||
mode: 'full',
|
mode: 'full',
|
||||||
loadAudioErrorPlayNext: false,
|
loadAudioErrorPlayNext: false,
|
||||||
autoPlayInitLoadPlayList: true,
|
autoPlayInitLoadPlayList: true,
|
||||||
@ -121,7 +128,7 @@ const Player = () => {
|
|||||||
),
|
),
|
||||||
locale: locale(translate),
|
locale: locale(translate),
|
||||||
}),
|
}),
|
||||||
[gainInfo, isDesktop, playerTheme, translate],
|
[gainInfo, isDesktop, playerTheme, translate, playerState.mode],
|
||||||
)
|
)
|
||||||
|
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
@ -294,6 +301,7 @@ const Player = () => {
|
|||||||
onAudioPlay={onAudioPlay}
|
onAudioPlay={onAudioPlay}
|
||||||
onAudioPlayTrackChange={onAudioPlayTrackChange}
|
onAudioPlayTrackChange={onAudioPlayTrackChange}
|
||||||
onAudioPause={onAudioPause}
|
onAudioPause={onAudioPause}
|
||||||
|
onPlayModeChange={(mode) => dispatch(setPlayMode(mode))}
|
||||||
onAudioEnded={onAudioEnded}
|
onAudioEnded={onAudioEnded}
|
||||||
onCoverClick={onCoverClick}
|
onCoverClick={onCoverClick}
|
||||||
onBeforeDestroy={onBeforeDestroy}
|
onBeforeDestroy={onBeforeDestroy}
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
PLAYER_SET_TRACK,
|
PLAYER_SET_TRACK,
|
||||||
PLAYER_SET_VOLUME,
|
PLAYER_SET_VOLUME,
|
||||||
PLAYER_SYNC_QUEUE,
|
PLAYER_SYNC_QUEUE,
|
||||||
|
PLAYER_SET_MODE,
|
||||||
} from '../actions'
|
} from '../actions'
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
|
|
||||||
@ -178,6 +179,13 @@ const reduceCurrent = (state, { data }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const reduceMode = (state, { data: { mode } }) => {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
mode,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const playerReducer = (previousState = initialState, payload) => {
|
export const playerReducer = (previousState = initialState, payload) => {
|
||||||
const { type } = payload
|
const { type } = payload
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -197,6 +205,8 @@ export const playerReducer = (previousState = initialState, payload) => {
|
|||||||
return reduceSyncQueue(previousState, payload)
|
return reduceSyncQueue(previousState, payload)
|
||||||
case PLAYER_CURRENT:
|
case PLAYER_CURRENT:
|
||||||
return reduceCurrent(previousState, payload)
|
return reduceCurrent(previousState, payload)
|
||||||
|
case PLAYER_SET_MODE:
|
||||||
|
return reduceMode(previousState, payload)
|
||||||
default:
|
default:
|
||||||
return previousState
|
return previousState
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ const SharePlayer = () => {
|
|||||||
src: shareDownloadUrl(shareInfo?.id),
|
src: shareDownloadUrl(shareInfo?.id),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
console.log(list)
|
|
||||||
const options = {
|
const options = {
|
||||||
audioLists: list,
|
audioLists: list,
|
||||||
mode: 'full',
|
mode: 'full',
|
||||||
|
@ -58,7 +58,12 @@ const createAdminStore = ({
|
|||||||
const state = store.getState()
|
const state = store.getState()
|
||||||
saveState({
|
saveState({
|
||||||
theme: state.theme,
|
theme: state.theme,
|
||||||
player: pick(state.player, ['queue', 'volume', 'savedPlayIndex']),
|
player: pick(state.player, [
|
||||||
|
'mode',
|
||||||
|
'queue',
|
||||||
|
'volume',
|
||||||
|
'savedPlayIndex',
|
||||||
|
]),
|
||||||
albumView: state.albumView,
|
albumView: state.albumView,
|
||||||
settings: state.settings,
|
settings: state.settings,
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user