Browse Source

controller code

pull/191/head
Phillip 1 year ago
parent
commit
a438f9db6a
  1. 16
      core/src/notifications/controller.js

16
core/src/notifications/controller.js

@ -1,7 +1,7 @@
import config from './config'
import { dispatcher } from './dispatcher'
import snackbar from '../functional-components/snackbar.js'
import { NEW_MESSAGE, NEW_MESSAGE_NOTIFICATION_QAPP } from './types'
import { NEW_MESSAGE, NEW_MESSAGE_NOTIFICATION_QAPP, NEW_MESSAGE_NOTIFICATION_QAPP_LOCAL } from './types'
let initial = 0
let _state
@ -43,8 +43,8 @@ const notificationCheck = function () {
*/
export const doNewMessage = function (req) {
const newMessage = () => {
let data
if (req.type && req.type === 'qapp') {
data = req
@ -73,10 +73,16 @@ export const doNewMessage = function (req) {
} else {
_state = notificationState
}
}
}
const page = window.top.location.href
if (!document.hasFocus()) {
if(req.type && req.type === 'qapp-local-notification'){
try {
dispatcher({ type: NEW_MESSAGE_NOTIFICATION_QAPP_LOCAL, data: req })
} catch (error) {
console.log('error', error)
}
}else if (!document.hasFocus()) {
newMessage()
} else {
if (page.includes(req.url) === false) {

Loading…
Cancel
Save