Rename actions

This commit is contained in:
Deluan
2020-05-16 15:03:02 -04:00
committed by Deluan Quintão
parent e81a9dd1b5
commit 5c95eed517
+7 -7
View File
@@ -1,11 +1,11 @@
import 'react-jinke-music-player/assets/index.css' import 'react-jinke-music-player/assets/index.css'
import subsonic from '../subsonic' import subsonic from '../subsonic'
const PLAYER_ADD_TRACK = 'PLAYER_ADD_TRACK' const PLAYER_ADD_TRACKS = 'PLAYER_ADD_TRACKS'
const PLAYER_SET_TRACK = 'PLAYER_SET_TRACK' const PLAYER_SET_TRACK = 'PLAYER_SET_TRACK'
const PLAYER_SYNC_QUEUE = 'PLAYER_SYNC_QUEUE' const PLAYER_SYNC_QUEUE = 'PLAYER_SYNC_QUEUE'
const PLAYER_SCROBBLE = 'PLAYER_SCROBBLE' const PLAYER_SCROBBLE = 'PLAYER_SCROBBLE'
const PLAYER_PLAY_ALBUM = 'PLAYER_PLAY_ALBUM' const PLAYER_PLAY_TRACKS = 'PLAYER_PLAY_TRACKS'
const mapToAudioLists = (item) => { const mapToAudioLists = (item) => {
// If item comes from a playlist, id is mediaFileId // If item comes from a playlist, id is mediaFileId
@@ -36,7 +36,7 @@ let filterAlbumSongs = function (data, ids) {
const addTracks = (data, ids) => { const addTracks = (data, ids) => {
const songs = filterAlbumSongs(data, ids) const songs = filterAlbumSongs(data, ids)
return { return {
type: PLAYER_ADD_TRACK, type: PLAYER_ADD_TRACKS,
data: songs, data: songs,
} }
} }
@@ -57,7 +57,7 @@ const shuffleTracks = (data, ids) => {
const shuffled = shuffle(songs) const shuffled = shuffle(songs)
const firstId = Object.keys(shuffled)[0] const firstId = Object.keys(shuffled)[0]
return { return {
type: PLAYER_PLAY_ALBUM, type: PLAYER_PLAY_TRACKS,
id: firstId, id: firstId,
data: shuffled, data: shuffled,
} }
@@ -66,7 +66,7 @@ const shuffleTracks = (data, ids) => {
const playTracks = (data, ids, selectedId) => { const playTracks = (data, ids, selectedId) => {
const songs = filterAlbumSongs(data, ids) const songs = filterAlbumSongs(data, ids)
return { return {
type: PLAYER_PLAY_ALBUM, type: PLAYER_PLAY_TRACKS,
id: selectedId || Object.keys(songs)[0], id: selectedId || Object.keys(songs)[0],
data: songs, data: songs,
} }
@@ -91,7 +91,7 @@ const playQueueReducer = (
let queue let queue
const { type, data } = payload const { type, data } = payload
switch (type) { switch (type) {
case PLAYER_ADD_TRACK: case PLAYER_ADD_TRACKS:
queue = previousState.queue queue = previousState.queue
Object.keys(data).forEach((id) => { Object.keys(data).forEach((id) => {
queue.push(mapToAudioLists(data[id])) queue.push(mapToAudioLists(data[id]))
@@ -124,7 +124,7 @@ const playQueueReducer = (
clear: false, clear: false,
playing: true, playing: true,
} }
case PLAYER_PLAY_ALBUM: case PLAYER_PLAY_TRACKS:
queue = [] queue = []
let match = false let match = false
Object.keys(data).forEach((id) => { Object.keys(data).forEach((id) => {