Missing upgraded position and volume controls

This commit is contained in:
James Barnsley
2018-03-02 08:07:30 +13:00
parent 1a89f8f91c
commit b74c6bc3e8
3 changed files with 43 additions and 15 deletions

View File

@ -154,9 +154,9 @@ export function getTimePosition(){
}
}
export function setTimePosition(time_position){
export function timePosition(time_position){
return {
type: 'MOPIDY_SET_TIME_POSITION',
type: 'MOPIDY_TIME_POSITION',
time_position: time_position
}
}
@ -396,8 +396,7 @@ export function getSearchResults(context, query, limit = 100){
export function getQueueHistory(){
return {
type: 'MOPIDY_GET_HISTORY'
type: 'MOPIDY_GET_QUEUE_HISTORY'
}
return instruct('history.getHistory')
}

View File

@ -54,7 +54,7 @@ const MopidyMiddleware = (function(){
// otherwise we just assume to add 1000ms every 1000ms of play time
} else {
store.dispatch(mopidyActions.setTimePosition(store.getState().mopidy.time_position + 1000 ))
store.dispatch(mopidyActions.timePosition(store.getState().mopidy.time_position + 1000 ))
}
progress_interval_counter++
@ -81,7 +81,7 @@ const MopidyMiddleware = (function(){
break;
case 'event:seeked':
store.dispatch({ type: 'MOPIDY_TIMEPOSITION', data: data.time_position});
store.dispatch({ type: 'MOPIDY_TIME_POSITION', time_position: data.time_position});
break;
case 'event:trackPlaybackEnded':
@ -93,11 +93,11 @@ const MopidyMiddleware = (function(){
break;
case 'event:volumeChanged':
store.dispatch({type: 'MOPIDY_VOLUME', data: data.volume});
store.dispatch({type: 'MOPIDY_VOLUME', volume: data.volume});
break;
case 'event:muteChanged':
store.dispatch({type: 'MOPIDY_MUTE', data: data.mute});
store.dispatch({type: 'MOPIDY_MUTE', mute: data.mute});
break;
case 'event:optionsChanged':
@ -403,11 +403,27 @@ const MopidyMiddleware = (function(){
break;
case 'MOPIDY_SET_VOLUME':
instruct(socket, store, 'playback.setVolume', {volume: action.volume});
instruct(socket, store, 'playback.setVolume', {volume: action.volume})
.then(
response => {
store.dispatch({
type: 'MOPIDY_VOLUME',
volume: action.volume
});
}
);
break;
case 'MOPIDY_SEEK':
instruct(socket, store, 'playback.seek', {time_position: action.time_position});
instruct(socket, store, 'playback.seek', {time_position: action.time_position})
.then(
response => {
store.dispatch({
type: 'MOPIDY_TIME_POSITION',
time_position: action.time_position
});
}
);
break;
case 'MOPIDY_GET_TIME_POSITION':
@ -1916,6 +1932,18 @@ const MopidyMiddleware = (function(){
);
break;
case 'MOPIDY_GET_QUEUE_HISTORY':
instruct(socket, store, 'history.getHistory')
.then(
response => {
store.dispatch({
type: 'MOPIDY_QUEUE_HISTORY',
tracks: helpers.formatTracks(response)
});
}
);
break;
case 'MOPIDY_GET_CURRENT_TRACK':
instruct(socket, store, 'playback.getCurrentTlTrack')
.then(

View File

@ -65,19 +65,20 @@ export default function reducer(mopidy = {}, action){
mute: action.mute
});
case 'MOPIDY_SET_TIME_POSITION':
case 'MOPIDY_TIME_POSITION':
return Object.assign({}, mopidy, {
time_position: action.time_position
});
case 'MOPIDY_HISTORY':
var history = []
for (var i = 0; i < action.data.length; i++){
case 'MOPIDY_QUEUE_HISTORY':
var history = [];
for (var i = 0; i < action.tracks.length; i++){
history.push(Object.assign(
{},
action.data[i][1],
action.tracks[i][1],
{
played_at: action.data[i][0],
played_at: action.tracks[i][0],
type: 'history'
}
))