import { SET_CURRENT_SONG , SET_FULL_SCREEN , SET_PLAYING_STATE , SET_SEQUENCE_PLAYLIST , SET_PLAYLIST , SET_PLAY_MODE , SET_CURRENT_INDEX , SET_SHOW_PLAYLIST , DELETE_SONG , INSERT_SONG , SET_CURRENT_LYRICS , } from './constants' ; import { getSongDetailRequest , getSongLyricRequest } from './services' ; export const changeCurrentSong = ( data ) => ( { type : SET_CURRENT_SONG , data , } ) ; export const changeFullScreen = ( data ) => ( { type : SET_FULL_SCREEN , data , } ) ; export const changePlayingState = ( data ) => ( { type : SET_PLAYING_STATE , data , } ) ; export const changeSequencePlayList = ( data ) => ( { type : SET_SEQUENCE_PLAYLIST , data , } ) ; export const changePlayList = ( data ) => ( { type : SET_PLAYLIST , data , } ) ; export const changePlayMode = ( data ) => ( { type : SET_PLAY_MODE , data , } ) ; export const changeCurrentIndex = ( data ) => ( { type : SET_CURRENT_INDEX , data , } ) ; export const changeShowPlayList = ( data ) => ( { type : SET_SHOW_PLAYLIST , data , } ) ; export const insertSong = ( data ) => ( { type : INSERT_SONG , data , } ) ; export const deleteSong = ( data ) => ( { type : DELETE_SONG , data , } ) ; export const changeCurrentLyrics = ( data ) => ( { type : SET_CURRENT_LYRICS , data , } ) ; export const getSongDetail = ( id ) => { return ( dispatch ) => { getSongDetailRequest ( id ) . then ( ( data ) => { let song = data . songs [ 0 ] ; dispatch ( insertSong ( song ) ) ; } ) ; } ; } ; export const getSongLyric = ( id ) => { return ( dispatch ) => { getSongLyricRequest ( id ) . then ( ( data ) => { let lyrics = { lyric : data . lrc ? data . lrc . lyric : undefined , tlyric : data . tlyric ? data . tlyric . lyric : undefined , } ; dispatch ( changeCurrentLyrics ( lyrics ) ) ; } ) ; } ; } ;