Playback history

This commit is contained in:
James Barnsley
2017-02-10 09:06:41 +13:00
parent 8c99d219eb
commit 5ac503bb3a
10 changed files with 353 additions and 185 deletions

View File

@ -225,4 +225,11 @@ export function getSearchResults(query, uris = null, fields = ['any']){
fields: fields
}
}
export function getQueueHistory(){
return {
type: 'MOPIDY_INSTRUCT',
call: 'history.getHistory'
}
}

View File

@ -163,7 +163,6 @@ const MopidyMiddleware = (function(){
instruct( socket, store, action.call, action.value )
break;
// send an instruction to the websocket
case 'MOPIDY_DEBUG':
instruct( socket, store, action.call, action.value )
.then( response => {
@ -171,7 +170,29 @@ const MopidyMiddleware = (function(){
})
break;
// send an instruction to the websocket
case 'MOPIDY_URISCHEMES':
var uri_schemes = action.data
var remove = ['http','https','mms','rtmp','rtmps','rtsp','sc','spotify']
// remove all our ignored types
for( var i = 0; i < remove.length; i++ ){
var index = uri_schemes.indexOf(remove[i])
if( index > -1 ) uri_schemes.splice(index, 1);
}
// append with ':' to make them a mopidy URI
for( var i = 0; i < uri_schemes.length; i++ ){
uri_schemes[i] = uri_schemes[i] +':'
}
store.dispatch({ type: 'MOPIDY_URISCHEMES_FILTERED', data: uri_schemes });
break;
/**
* General playback
**/
case 'MOPIDY_NEXT':
var icon = false
if( store.getState().ui.current_track ){
@ -212,24 +233,6 @@ const MopidyMiddleware = (function(){
})
break;
case 'MOPIDY_URISCHEMES':
var uri_schemes = action.data
var remove = ['http','https','mms','rtmp','rtmps','rtsp','sc','spotify']
// remove all our ignored types
for( var i = 0; i < remove.length; i++ ){
var index = uri_schemes.indexOf(remove[i])
if( index > -1 ) uri_schemes.splice(index, 1);
}
// append with ':' to make them a mopidy URI
for( var i = 0; i < uri_schemes.length; i++ ){
uri_schemes[i] = uri_schemes[i] +':'
}
store.dispatch({ type: 'MOPIDY_URISCHEMES_FILTERED', data: uri_schemes });
break;
case 'MOPIDY_ENQUEUE_URIS_NEXT':
var current_track = store.getState().ui.current_track

View File

@ -62,6 +62,22 @@ export default function reducer(mopidy = {}, action){
time_position: action.data
});
case 'MOPIDY_HISTORY':
var history = []
for (var i = 0; i < action.data.length; i++){
history.push(Object.assign(
{},
action.data[i][1],
{
played_at: action.data[i][0],
type: 'history'
}
))
}
return Object.assign({}, mopidy, {
queue_history: history
});
/**
* Asset-oriented actions