Reducing usage of browser notifications in favor of in-app notifications
This commit is contained in:
@ -175,20 +175,22 @@ export function createBrowserNotification(data){
|
||||
}
|
||||
}
|
||||
|
||||
export function createNotification(content, type = 'default', key = null, title = null, description = null, sticky = false){
|
||||
if (!key){
|
||||
key = helpers.generateGuid()
|
||||
}
|
||||
// content, type = 'default', key = null, title = null, description = null, sticky = false
|
||||
|
||||
export function createNotification(data){
|
||||
return {
|
||||
type: 'CREATE_NOTIFICATION',
|
||||
notification: {
|
||||
key: key,
|
||||
type: type,
|
||||
title: title,
|
||||
description: description,
|
||||
content: content,
|
||||
sticky: sticky
|
||||
}
|
||||
notification: Object.assign(
|
||||
{
|
||||
key: helpers.generateGuid(),
|
||||
type: 'default',
|
||||
title: null,
|
||||
content: null,
|
||||
description: null,
|
||||
sticky: false
|
||||
},
|
||||
data
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ const UIMiddleware = (function(){
|
||||
* The actual middleware inteceptor
|
||||
**/
|
||||
return store => next => action => {
|
||||
|
||||
switch(action.type){
|
||||
|
||||
case 'MOPIDY_STATE':
|
||||
@ -117,14 +116,14 @@ const UIMiddleware = (function(){
|
||||
|
||||
if (!suppressed_broadcasts.includes(broadcast.key)){
|
||||
if (broadcast.message){
|
||||
store.dispatch(uiActions.createNotification(
|
||||
broadcast.message,
|
||||
'broadcast',
|
||||
(broadcast.key ? broadcast.key : null),
|
||||
(broadcast.title ? broadcast.title : null),
|
||||
null,
|
||||
true
|
||||
))
|
||||
var data = {
|
||||
key: (broadcast.key ? broadcast.key : null),
|
||||
title: (broadcast.title ? broadcast.title : null),
|
||||
content: broadcast.message,
|
||||
type: 'broadcast',
|
||||
sticky: true
|
||||
}
|
||||
store.dispatch(uiActions.createNotification(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user