Files
salvato.newfreeplanet/src/globalroutines/index.ts
paoloar77 ce20daed6d 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.
2022-08-07 02:01:20 +02:00

35 lines
1.1 KiB
TypeScript
Executable File

// import { useGlobalStore } from '@store/globalStore'
import indexdb from './indexdb'
import { idbKeyval as storage } from '@src/js/storage'
export default async (cmd: string, table: string, data: any = null, id: any = '') => {
// const globalStore = useGlobalStore()
// const descr = data !== null ? data.descr : ''
// console.log('globalroutines', cmd, table, descr, id)
// return storage.setdata(table, data)
return indexdb( cmd, table, data, id)
.then((ris) => {
// console.log('globalStore.state.connData', globalStore.state.connData)
setTimeout(() => {
// globalStore.connData.uploading_indexeddb = 0
// globalStore.connData.downloading_indexeddb = 0
}, 1000)
return ris
}).catch((err) => {
setTimeout(() => {
// globalStore.connData.uploading_indexeddb = (globalStore.connData.uploading_indexeddb === 1) ? -1 : globalStore.connData.uploading_indexeddb
// globalStore.connData.downloading_indexeddb = (globalStore.connData.downloading_indexeddb === 1) ? -1 : globalStore.connData.downloading_indexeddb
}, 1000)
console.log('ERROR INDEXEDDB: ', err)
})
}