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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user