http-request-manager 18.13.12 → 18.13.14
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: {} };
|
|
@@ -923,6 +923,7 @@ class QueryParamsTrackerService {
|
|
|
923
923
|
}
|
|
924
924
|
checkRequestOptions(requestOptions = [], options = {}) {
|
|
925
925
|
this.ensureStateRestored();
|
|
926
|
+
this.tryHydrateStateFromPersistedStore();
|
|
926
927
|
const normalized = this.normalizeRequestOptions(requestOptions);
|
|
927
928
|
if (!normalized.pathKey)
|
|
928
929
|
return false;
|
|
@@ -944,6 +945,7 @@ class QueryParamsTrackerService {
|
|
|
944
945
|
}
|
|
945
946
|
matchesPath(requestOptions = [], expectedPathOptions = []) {
|
|
946
947
|
this.ensureStateRestored();
|
|
948
|
+
this.tryHydrateStateFromPersistedStore();
|
|
947
949
|
const requestPath = this.normalizeRequestOptions(requestOptions).pathKey;
|
|
948
950
|
const expectedPath = this.normalizeRequestOptions(expectedPathOptions).pathKey;
|
|
949
951
|
return Boolean(requestPath) && requestPath === expectedPath;
|
|
@@ -1159,10 +1161,8 @@ class QueryParamsTrackerService {
|
|
|
1159
1161
|
sessionStorage.setItem(TRACKER_SESSION_INIT_KEY, '1');
|
|
1160
1162
|
}
|
|
1161
1163
|
restoreState() {
|
|
1162
|
-
|
|
1163
|
-
if (this.
|
|
1164
|
-
this.state = QueryTrackerStateModel.adapt(syncState);
|
|
1165
|
-
this.cleanupExpiredEntries();
|
|
1164
|
+
this.tryHydrateStateFromPersistedStore();
|
|
1165
|
+
if (Object.keys(this.state.paths).length > 0) {
|
|
1166
1166
|
return;
|
|
1167
1167
|
}
|
|
1168
1168
|
this.localStorageManager.store$(TRACKER_STORE_NAME)
|
|
@@ -1186,6 +1186,17 @@ class QueryParamsTrackerService {
|
|
|
1186
1186
|
}
|
|
1187
1187
|
});
|
|
1188
1188
|
}
|
|
1189
|
+
tryHydrateStateFromPersistedStore() {
|
|
1190
|
+
if (Object.keys(this.state.paths).length > 0) {
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
const syncState = this.localStorageManager.getPersistedStoreSync(TRACKER_STORE_NAME);
|
|
1194
|
+
if (!this.isTrackerState(syncState)) {
|
|
1195
|
+
return;
|
|
1196
|
+
}
|
|
1197
|
+
this.state = QueryTrackerStateModel.adapt(syncState);
|
|
1198
|
+
this.cleanupExpiredEntries();
|
|
1199
|
+
}
|
|
1189
1200
|
persistState() {
|
|
1190
1201
|
this.localStorageManager.storeExists$(TRACKER_STORE_NAME)
|
|
1191
1202
|
.pipe(take(1))
|
|
@@ -5463,6 +5474,59 @@ class LocalStorageManagerService extends ComponentStore {
|
|
|
5463
5474
|
return storageData;
|
|
5464
5475
|
}
|
|
5465
5476
|
}
|
|
5477
|
+
getPersistedStoreSync(storeName) {
|
|
5478
|
+
storeName = this.validStoreName(String(storeName || ''));
|
|
5479
|
+
if (!storeName || !this.app?.appID) {
|
|
5480
|
+
return null;
|
|
5481
|
+
}
|
|
5482
|
+
const settingsStr = localStorage.getItem(this.storageSettingsName);
|
|
5483
|
+
if (!settingsStr) {
|
|
5484
|
+
return null;
|
|
5485
|
+
}
|
|
5486
|
+
let settings = [];
|
|
5487
|
+
try {
|
|
5488
|
+
const decryptedSettings = this.encryption.decrypt(settingsStr, this.app.appID);
|
|
5489
|
+
settings = decryptedSettings ? JSON.parse(decryptedSettings) : [];
|
|
5490
|
+
}
|
|
5491
|
+
catch {
|
|
5492
|
+
return null;
|
|
5493
|
+
}
|
|
5494
|
+
const foundSetting = settings.find(item => item.name === storeName);
|
|
5495
|
+
if (!foundSetting) {
|
|
5496
|
+
return null;
|
|
5497
|
+
}
|
|
5498
|
+
const rawStores = foundSetting.options?.storage === StorageType.GLOBAL
|
|
5499
|
+
? localStorage.getItem(this.storageName)
|
|
5500
|
+
: sessionStorage.getItem(this.storageName);
|
|
5501
|
+
if (!rawStores) {
|
|
5502
|
+
return null;
|
|
5503
|
+
}
|
|
5504
|
+
let stores = [];
|
|
5505
|
+
try {
|
|
5506
|
+
stores = JSON.parse(rawStores);
|
|
5507
|
+
}
|
|
5508
|
+
catch {
|
|
5509
|
+
return null;
|
|
5510
|
+
}
|
|
5511
|
+
const foundStore = stores.find(item => item.id === foundSetting.id);
|
|
5512
|
+
if (!foundStore) {
|
|
5513
|
+
return null;
|
|
5514
|
+
}
|
|
5515
|
+
const options = SettingOptions.adapt(foundSetting.options);
|
|
5516
|
+
let storageData = foundStore.data;
|
|
5517
|
+
if (options.encrypted) {
|
|
5518
|
+
const decryptedData = this.encryption.decrypt(foundStore.data, this.app.appID);
|
|
5519
|
+
if (decryptedData !== null) {
|
|
5520
|
+
storageData = decryptedData;
|
|
5521
|
+
}
|
|
5522
|
+
}
|
|
5523
|
+
try {
|
|
5524
|
+
return this.isString(storageData) ? JSON.parse(storageData) : storageData;
|
|
5525
|
+
}
|
|
5526
|
+
catch {
|
|
5527
|
+
return storageData;
|
|
5528
|
+
}
|
|
5529
|
+
}
|
|
5466
5530
|
startTimer() {
|
|
5467
5531
|
const timer$ = interval(1000 * 3).pipe(withLatestFrom(this.data$), map(([_, state]) => state), tap((state) => {
|
|
5468
5532
|
const expired = this.expired(state) ? this.expired(state) : [];
|