Notification with Service Workers now is working!
When a Notification arrives, it save into the IndexDb, then in Vue.js call a polling to check in the db if there is a different record count. If is different then call a get to update the notification.
This commit is contained in:
@@ -564,6 +564,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
|
||||
async createPushSubscription() {
|
||||
|
||||
// console.log('ENTER TO createPushSubscription')
|
||||
// If Already subscribed, don't send to the Server DB
|
||||
// if (state.wasAlreadySubOnDb) {
|
||||
// // console.log('wasAlreadySubOnDb!')
|
||||
@@ -574,10 +575,12 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
return
|
||||
|
||||
if (!('serviceWorker' in navigator)) {
|
||||
console.log('serviceWorker not present !')
|
||||
return
|
||||
}
|
||||
|
||||
if (!('PushManager' in window)) {
|
||||
console.log('PushManager not present !')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1657,12 +1660,23 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
|
||||
getServerHost() {
|
||||
|
||||
if (this.serverHost) {
|
||||
return this.serverHost
|
||||
} else {
|
||||
return process.env.MONGODB_HOST
|
||||
let myserv = ''
|
||||
myserv = window.location.host
|
||||
|
||||
if (process.env.DEBUGGING) {
|
||||
myserv = 'http://192.168.1.54:3000'
|
||||
}
|
||||
|
||||
if (!myserv) {
|
||||
if (this.serverHost) {
|
||||
myserv = this.serverHost
|
||||
} else {
|
||||
myserv = process.env.MONGODB_HOST!
|
||||
}
|
||||
}
|
||||
|
||||
return myserv
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user