Fix Db initialisation issue

This commit is contained in:
NicolasCantu 2024-12-19 11:17:40 +01:00
parent 62c8d95ea3
commit bcf405e3c5

View File

@ -72,9 +72,11 @@ class Database {
};
request.onsuccess = () => {
this.db = request.result;
this.initServiceWorker();
resolve();
setTimeout(() => {
this.db = request.result;
this.initServiceWorker();
resolve();
}, 0);
};
request.onerror = () => {
@ -111,9 +113,8 @@ class Database {
const registration = await navigator.serviceWorker.register('/src/service-workers/database.worker.js', { type: 'module' });
console.log('Service Worker registered with scope:', registration.scope);
this.serviceWorkerRegistration = registration;
this.checkForUpdates();
this.serviceWorkerRegistration = registration
await this.checkForUpdates();
// Set up the message channels
this.messageChannel.port1.onmessage = this.handleAddObjectResponse;