Queue changes broadcast notifications in browser

This commit is contained in:
James Barnsley
2018-02-25 17:24:24 +13:00
parent 2c0d75612f
commit 536fead38d
3 changed files with 47 additions and 17 deletions

View File

@ -42,7 +42,10 @@ export function debug(call, value){
**/
export function changeTrack(tlid){
return instruct('playback.play', {tlid: tlid})
return {
type: 'MOPIDY_CHANGE_TRACK',
tlid: tlid
}
}
export function playURIs(uris, from_uri = null){
@ -85,7 +88,10 @@ export function playAlbum(uri){
}
export function removeTracks(tlids){
return instruct('tracklist.remove', {tlid: tlids})
return {
type: 'MOPIDY_REMOVE_TRACKS',
tlids: tlids
}
}
export function reorderTracklist(indexes, insert_before){

View File

@ -276,7 +276,6 @@ const MopidyMiddleware = (function(){
case 'MOPIDY_PAUSE':
var data = {
key: 'playback',
type: 'notification',
notification_type: 'info',
content: store.getState().pusher.username +' paused playback',
@ -287,7 +286,6 @@ const MopidyMiddleware = (function(){
case 'MOPIDY_NEXT':
var data = {
key: 'playback',
type: 'notification',
notification_type: 'info',
content: store.getState().pusher.username +' skipped <em>'+store.getState().core.current_track.name+'</em>',
@ -298,7 +296,6 @@ const MopidyMiddleware = (function(){
case 'MOPIDY_STOP':
var data = {
key: 'playback',
type: 'notification',
notification_type: 'info',
content: store.getState().pusher.username +' stopped playback',
@ -307,6 +304,28 @@ const MopidyMiddleware = (function(){
store.dispatch(pusherActions.deliverBroadcast(data));
break
case 'MOPIDY_CHANGE_TRACK':
instruct(socket, store, 'playback.play', {tlid: action.tlid});
var broadcast_data = {
type: 'notification',
notification_type: 'info',
content: store.getState().pusher.username +' changed track'
}
store.dispatch(pusherActions.deliverBroadcast(broadcast_data));
break;
case 'MOPIDY_REMOVE_TRACKS':
instruct(socket, store, 'tracklist.remove', {tlid: action.tlids});
var broadcast_data = {
type: 'notification',
notification_type: 'info',
content: store.getState().pusher.username +' removed '+action.tlids.length+' tracks'
}
store.dispatch(pusherActions.deliverBroadcast(broadcast_data));
break;
case 'MOPIDY_PLAY_PLAYLIST':
// Clear tracklist (if set)
@ -361,6 +380,14 @@ const MopidyMiddleware = (function(){
break;
}
var broadcast_data = {
type: 'notification',
notification_type: 'info',
content: store.getState().pusher.username +' is adding '+action.uris.length+' URIs to queue',
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
}
store.dispatch(pusherActions.deliverBroadcast(broadcast_data));
// split into batches
var uris = Object.assign([], action.uris)
var batches = []
@ -494,15 +521,6 @@ const MopidyMiddleware = (function(){
break;
}
var broadcast_data = {
key: 'playback',
type: 'notification',
notification_type: 'info',
content: store.getState().pusher.username +' is playing '+action.uris.length+' URIs',
icon: (store.getState().core.current_track ? helpers.getTrackIcon(store.getState().core.current_track, store.getState().core) : false)
}
store.dispatch(pusherActions.deliverBroadcast(broadcast_data));
// Stop the radio
if (store.getState().core.radio && store.getState().core.radio.enabled){
store.dispatch(pusherActions.stopRadio());
@ -513,7 +531,7 @@ const MopidyMiddleware = (function(){
store.dispatch(mopidyActions.clearTracklist());
}
var first_uri = action.uris[0]
var first_uri = action.uris[0];
// add our first track
instruct(socket, store, 'tracklist.add', { uri: first_uri, at_position: 0 })

View File

@ -105,8 +105,14 @@ $bp_shallow: 650px;
}
@keyframes fadein {
0% { opacity: 0; }
100% { opacity: 1; }
0% {
opacity: 0;
transform: translateY(5px);
}
100% {
opacity: 1;
transform: translateY(0px);
}
}
@mixin fadein($duration: 0.2s){