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:
paoloar77
2022-08-07 02:01:20 +02:00
parent 66ee007e92
commit ce20daed6d
27 changed files with 411 additions and 232 deletions

View File

@@ -1,4 +1,4 @@
const OtherTables = ['categories', 'config', 'swmsg']
const OtherTables = ['categories', 'config', 'swmsg', 'notifications']
const MainTables = ['todos', 'projects']
const allMethod = ['sync_post_', 'sync_patch_', 'delete_']
@@ -13,7 +13,7 @@ let idbKeyval = (() => {
if (!db) {
// console.log('CREO DB STORAGE JS !')
db = new Promise((resolve, reject) => {
const openreq = indexedDB.open('mydb3', 11);
const openreq = indexedDB.open('mydb3', 13);
openreq.onerror = () => {
reject(openreq.error);
@@ -84,12 +84,19 @@ let idbKeyval = (() => {
async getdata(table, key) {
let req;
console.log('getdata', table, key)
await withStore('readonly', table, store => {
// console.log('store', store, 'key', key)
req = store.get(key);
// console.log(' req', req)
});
return req.result;
if (req) {
return req.result;
} else {
return null;
}
},
async getalldata(table) {
let req;