fix(ihm_client): double fallback IndexedDB si service worker.ready échoue
All checks were successful
Build and Push Docker image (ext) / docker (push) Successful in 52s
All checks were successful
Build and Push Docker image (ext) / docker (push) Successful in 52s
This commit is contained in:
parent
c21eb9170a
commit
a40416a248
@ -308,8 +308,28 @@ export class Database {
|
|||||||
|
|
||||||
// Check if the service worker is active
|
// Check if the service worker is active
|
||||||
if (!this.serviceWorkerRegistration) {
|
if (!this.serviceWorkerRegistration) {
|
||||||
|
try {
|
||||||
// console.warn('Service worker registration is not ready. Waiting...');
|
// console.warn('Service worker registration is not ready. Waiting...');
|
||||||
this.serviceWorkerRegistration = await navigator.serviceWorker.ready;
|
this.serviceWorkerRegistration = await navigator.serviceWorker.ready;
|
||||||
|
} catch (error) {
|
||||||
|
// Si le service worker n'est pas disponible, fallback vers IndexedDB direct
|
||||||
|
console.warn('Service worker not available, falling back to direct IndexedDB');
|
||||||
|
try {
|
||||||
|
const db = await this.getDb();
|
||||||
|
const tx = (db as any).transaction(payload.storeName, 'readwrite');
|
||||||
|
const store = tx.objectStore(payload.storeName);
|
||||||
|
if (payload.key) {
|
||||||
|
await store.put(payload.object, payload.key);
|
||||||
|
} else {
|
||||||
|
await store.put(payload.object);
|
||||||
|
}
|
||||||
|
resolve();
|
||||||
|
return;
|
||||||
|
} catch (dbError: any) {
|
||||||
|
reject(new Error(dbError?.message || 'IndexedDB write failed'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeWorker = await this.waitForServiceWorkerActivation(this.serviceWorkerRegistration);
|
const activeWorker = await this.waitForServiceWorkerActivation(this.serviceWorkerRegistration);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user