Browser notifications now working
This commit is contained in:
@ -198,43 +198,23 @@ const MopidyMiddleware = (function(){
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
case 'MOPIDY_NEXT':
|
case 'MOPIDY_NEXT':
|
||||||
var icon = false
|
var data = {
|
||||||
if( store.getState().ui.current_track ){
|
type: 'browser_notification',
|
||||||
icon = helpers.getTrackIcon( store.getState().ui.current_track )
|
title: 'Track skipped',
|
||||||
|
body: store.getState().pusher.username +' skipped this track',
|
||||||
|
icon: (store.getState().ui.current_track ? helpers.getTrackIcon( store.getState().ui.current_track ) : false)
|
||||||
}
|
}
|
||||||
store.dispatch({
|
store.dispatch( pusherActions.deliverBroadcast(data) )
|
||||||
type: 'PUSHER_SEND_BROADCAST',
|
|
||||||
action: 'broadcast',
|
|
||||||
ignore_self: true,
|
|
||||||
data: {
|
|
||||||
type: 'notification',
|
|
||||||
data: {
|
|
||||||
title: 'Track skipped',
|
|
||||||
body: store.getState().pusher.username +' skipped this track',
|
|
||||||
icon: icon
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'MOPIDY_STOP':
|
case 'MOPIDY_STOP':
|
||||||
var icon = false
|
var data = {
|
||||||
if( store.getState().ui.current_track ){
|
type: 'browser_notification',
|
||||||
icon = helpers.getTrackIcon( store.getState().ui.current_track )
|
title: 'Playback stopped',
|
||||||
|
body: store.getState().pusher.username +' stopped playback',
|
||||||
|
icon: (store.getState().ui.current_track ? helpers.getTrackIcon( store.getState().ui.current_track ) : false)
|
||||||
}
|
}
|
||||||
store.dispatch({
|
store.dispatch( pusherActions.deliverBroadcast(data) )
|
||||||
type: 'PUSHER_SEND_BROADCAST',
|
|
||||||
action: 'broadcast',
|
|
||||||
ignore_self: true,
|
|
||||||
data: {
|
|
||||||
type: 'notification',
|
|
||||||
data: {
|
|
||||||
title: 'Playback stopped',
|
|
||||||
body: store.getState().pusher.username +' stopped playback',
|
|
||||||
icon: icon
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'MOPIDY_ENQUEUE_URIS':
|
case 'MOPIDY_ENQUEUE_URIS':
|
||||||
|
|||||||
@ -48,6 +48,13 @@ export function instruct( data = null ){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function deliverBroadcast( data = null ){
|
||||||
|
return {
|
||||||
|
type: 'PUSHER_DELIVER_BROADCAST',
|
||||||
|
data: data
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function sendAuthorization( recipient_connectionid, authorization, me ){
|
export function sendAuthorization( recipient_connectionid, authorization, me ){
|
||||||
return {
|
return {
|
||||||
type: 'PUSHER_DELIVER_MESSAGE',
|
type: 'PUSHER_DELIVER_MESSAGE',
|
||||||
|
|||||||
@ -159,7 +159,7 @@ const PusherMiddleware = (function(){
|
|||||||
break
|
break
|
||||||
|
|
||||||
case 'PUSHER_DELIVER_MESSAGE':
|
case 'PUSHER_DELIVER_MESSAGE':
|
||||||
request('deliver_message', action)
|
request('deliver_message', action.data)
|
||||||
.then(
|
.then(
|
||||||
response => {
|
response => {
|
||||||
store.dispatch( uiActions.createNotification('Message delivered') )
|
store.dispatch( uiActions.createNotification('Message delivered') )
|
||||||
@ -167,6 +167,10 @@ const PusherMiddleware = (function(){
|
|||||||
)
|
)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case 'PUSHER_DELIVER_BROADCAST':
|
||||||
|
request('broadcast', action.data)
|
||||||
|
break
|
||||||
|
|
||||||
case 'PUSHER_GET_QUEUE_METADATA':
|
case 'PUSHER_GET_QUEUE_METADATA':
|
||||||
request('get_queue_metadata')
|
request('get_queue_metadata')
|
||||||
.then(
|
.then(
|
||||||
@ -276,10 +280,18 @@ const PusherMiddleware = (function(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we don't need to wait for response, as change will be broadcast
|
||||||
request( 'start_radio', data )
|
request( 'start_radio', data )
|
||||||
.then(response => {
|
break
|
||||||
console.log(response)
|
|
||||||
})
|
case 'PUSHER_RADIO_STARTED':
|
||||||
|
var data = {
|
||||||
|
type: 'browser_notification',
|
||||||
|
title: 'Radio',
|
||||||
|
body: 'Radio mode started',
|
||||||
|
icon: (store.getState().ui.current_track ? helpers.getTrackIcon( store.getState().ui.current_track ) : false)
|
||||||
|
}
|
||||||
|
store.dispatch( pusherActions.deliverBroadcast(data) )
|
||||||
break
|
break
|
||||||
|
|
||||||
case 'PUSHER_STOP_RADIO':
|
case 'PUSHER_STOP_RADIO':
|
||||||
@ -291,10 +303,20 @@ const PusherMiddleware = (function(){
|
|||||||
seed_tracks: []
|
seed_tracks: []
|
||||||
}
|
}
|
||||||
|
|
||||||
// we don't need to wait for request, as change will be broadcast
|
// we don't need to wait for response, as change will be broadcast
|
||||||
request( 'stop_radio', data )
|
request( 'stop_radio', data )
|
||||||
break
|
break
|
||||||
|
|
||||||
|
case 'PUSHER_RADIO_STOPPED':
|
||||||
|
var data = {
|
||||||
|
type: 'browser_notification',
|
||||||
|
title: 'Radio',
|
||||||
|
body: 'Radio mode stopped',
|
||||||
|
icon: (store.getState().ui.current_track ? helpers.getTrackIcon( store.getState().ui.current_track ) : false)
|
||||||
|
}
|
||||||
|
store.dispatch( pusherActions.deliverBroadcast(data) )
|
||||||
|
break
|
||||||
|
|
||||||
case 'PUSHER_BROWSER_NOTIFICATION':
|
case 'PUSHER_BROWSER_NOTIFICATION':
|
||||||
store.dispatch(uiActions.createBrowserNotification(action))
|
store.dispatch(uiActions.createBrowserNotification(action))
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user