@rdlabo/ionic-angular-kit 21.5.11 → 21.5.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2366,6 +2366,28 @@ class OfflineSyncService {
2366
2366
  if (options.flush !== false && this.#network.connected())
2367
2367
  this.#flushInBackground();
2368
2368
  }
2369
+ /** Clears a retry backoff selected explicitly by the user and sends the durable command now. */
2370
+ async retryNow(commandId) {
2371
+ await this.initialize();
2372
+ this.#invalidateFlush();
2373
+ await this.#waitForSendingTransitions();
2374
+ await this.#restoreInterruptedCommands();
2375
+ const retried = await this.runSerializedReplicaMutation(async (repository) => {
2376
+ // Re-read only after every interrupted transport transition has settled.
2377
+ // An ACK may have removed the command while retryNow was waiting; never
2378
+ // resurrect such a command from an object captured before invalidation.
2379
+ const current = (await this.#readKnownCommands()).find((item) => item.commandId === commandId);
2380
+ if (!current)
2381
+ return false;
2382
+ if (current.state !== 'retry_wait') {
2383
+ throw new Error(`Offline command ${commandId} is not waiting for retry.`);
2384
+ }
2385
+ await repository.putCommand({ ...current, state: 'pending', retryAt: null, lastErrorCode: null });
2386
+ return true;
2387
+ });
2388
+ if (retried && this.#network.connected())
2389
+ await this.flush();
2390
+ }
2369
2391
  async discardAllPending() {
2370
2392
  await this.initialize();
2371
2393
  this.#invalidateFlush();