http-request-manager 18.13.10 → 18.13.13

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.
@@ -910,9 +910,9 @@ const DEFAULT_TRACKER_OPTIONS = SettingOptions.adapt({
910
910
  });
911
911
  class QueryParamsTrackerService {
912
912
  constructor() {
913
+ this.localStorageManager = inject(LocalStorageManagerService);
913
914
  this.state = { paths: {} };
914
915
  this.stateRestored = false;
915
- this.localStorageManager = inject(LocalStorageManagerService);
916
916
  }
917
917
  clearTracking(resetSessionInit = false) {
918
918
  this.state = { paths: {} };
@@ -1159,6 +1159,12 @@ class QueryParamsTrackerService {
1159
1159
  sessionStorage.setItem(TRACKER_SESSION_INIT_KEY, '1');
1160
1160
  }
1161
1161
  restoreState() {
1162
+ const syncState = this.localStorageManager.getPersistedStoreSync(TRACKER_STORE_NAME);
1163
+ if (this.isTrackerState(syncState)) {
1164
+ this.state = QueryTrackerStateModel.adapt(syncState);
1165
+ this.cleanupExpiredEntries();
1166
+ return;
1167
+ }
1162
1168
  this.localStorageManager.store$(TRACKER_STORE_NAME)
1163
1169
  .pipe(take(1))
1164
1170
  .subscribe({
@@ -5429,6 +5435,87 @@ const storage = {
5429
5435
  settings: [],
5430
5436
  };
5431
5437
  class LocalStorageManagerService extends ComponentStore {
5438
+ getStoreSync(storeName) {
5439
+ storeName = storeName.toLowerCase();
5440
+ const data = this.get();
5441
+ const foundStore = data.settings.find(item => item.name === storeName);
5442
+ if (!foundStore) {
5443
+ return null;
5444
+ }
5445
+ const found = foundStore.options?.storage === StorageType.GLOBAL
5446
+ ? data.localStores.find(item => item.id === foundStore.id)
5447
+ : data.sessionStores.find(item => item.id === foundStore.id);
5448
+ if (!found || !this.app?.appID) {
5449
+ return null;
5450
+ }
5451
+ const options = SettingOptions.adapt(foundStore.options);
5452
+ let storageData = found.data;
5453
+ if (options.encrypted) {
5454
+ const decryptedData = this.encryption.decrypt(found.data, this.app.appID);
5455
+ if (decryptedData !== null) {
5456
+ storageData = decryptedData;
5457
+ }
5458
+ }
5459
+ try {
5460
+ return this.isString(storageData) ? JSON.parse(storageData) : storageData;
5461
+ }
5462
+ catch {
5463
+ return storageData;
5464
+ }
5465
+ }
5466
+ getPersistedStoreSync(storeName) {
5467
+ storeName = this.validStoreName(String(storeName || ''));
5468
+ if (!storeName || !this.app?.appID) {
5469
+ return null;
5470
+ }
5471
+ const settingsStr = localStorage.getItem(this.storageSettingsName);
5472
+ if (!settingsStr) {
5473
+ return null;
5474
+ }
5475
+ let settings = [];
5476
+ try {
5477
+ const decryptedSettings = this.encryption.decrypt(settingsStr, this.app.appID);
5478
+ settings = decryptedSettings ? JSON.parse(decryptedSettings) : [];
5479
+ }
5480
+ catch {
5481
+ return null;
5482
+ }
5483
+ const foundSetting = settings.find(item => item.name === storeName);
5484
+ if (!foundSetting) {
5485
+ return null;
5486
+ }
5487
+ const rawStores = foundSetting.options?.storage === StorageType.GLOBAL
5488
+ ? localStorage.getItem(this.storageName)
5489
+ : sessionStorage.getItem(this.storageName);
5490
+ if (!rawStores) {
5491
+ return null;
5492
+ }
5493
+ let stores = [];
5494
+ try {
5495
+ stores = JSON.parse(rawStores);
5496
+ }
5497
+ catch {
5498
+ return null;
5499
+ }
5500
+ const foundStore = stores.find(item => item.id === foundSetting.id);
5501
+ if (!foundStore) {
5502
+ return null;
5503
+ }
5504
+ const options = SettingOptions.adapt(foundSetting.options);
5505
+ let storageData = foundStore.data;
5506
+ if (options.encrypted) {
5507
+ const decryptedData = this.encryption.decrypt(foundStore.data, this.app.appID);
5508
+ if (decryptedData !== null) {
5509
+ storageData = decryptedData;
5510
+ }
5511
+ }
5512
+ try {
5513
+ return this.isString(storageData) ? JSON.parse(storageData) : storageData;
5514
+ }
5515
+ catch {
5516
+ return storageData;
5517
+ }
5518
+ }
5432
5519
  startTimer() {
5433
5520
  const timer$ = interval(1000 * 3).pipe(withLatestFrom(this.data$), map(([_, state]) => state), tap((state) => {
5434
5521
  const expired = this.expired(state) ? this.expired(state) : [];