@hmcts/rpx-xui-common-lib 3.2.25 → 3.2.26-ts-node-update
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.
|
@@ -2149,8 +2149,12 @@ class FilterService {
|
|
|
2149
2149
|
this.streams = {};
|
|
2150
2150
|
}
|
|
2151
2151
|
persist(setting, persistence) {
|
|
2152
|
+
setting = { ...setting };
|
|
2153
|
+
delete setting.idamId;
|
|
2152
2154
|
switch (persistence) {
|
|
2153
2155
|
case 'local':
|
|
2156
|
+
this.persistLocal(setting);
|
|
2157
|
+
break;
|
|
2154
2158
|
case 'session':
|
|
2155
2159
|
this.persistSession(setting);
|
|
2156
2160
|
break;
|
|
@@ -2162,14 +2166,33 @@ class FilterService {
|
|
|
2162
2166
|
}
|
|
2163
2167
|
get(id) {
|
|
2164
2168
|
if (this.filterSettings[id]) {
|
|
2165
|
-
|
|
2169
|
+
const setting = this.filterSettings[id];
|
|
2170
|
+
return !setting.ownerHash || this.isSameUser(setting) ? setting : null;
|
|
2171
|
+
}
|
|
2172
|
+
const localSetting = localStorage.getItem(id);
|
|
2173
|
+
if (localSetting) {
|
|
2174
|
+
const setting = JSON.parse(localSetting);
|
|
2175
|
+
if (this.isSameUser(setting)) {
|
|
2176
|
+
// A legacy session entry must not override the restored local filter.
|
|
2177
|
+
sessionStorage.removeItem(id);
|
|
2178
|
+
return setting;
|
|
2179
|
+
}
|
|
2180
|
+
localStorage.removeItem(id);
|
|
2166
2181
|
}
|
|
2167
|
-
const
|
|
2168
|
-
if (
|
|
2169
|
-
return JSON.parse(
|
|
2182
|
+
const sessionSetting = sessionStorage.getItem(id);
|
|
2183
|
+
if (sessionSetting) {
|
|
2184
|
+
return JSON.parse(sessionSetting);
|
|
2170
2185
|
}
|
|
2171
2186
|
return null;
|
|
2172
2187
|
}
|
|
2188
|
+
isSameUser(setting) {
|
|
2189
|
+
const ownerHash = this.getOwnerHash();
|
|
2190
|
+
return !!ownerHash && setting.ownerHash === ownerHash;
|
|
2191
|
+
}
|
|
2192
|
+
getOwnerHash() {
|
|
2193
|
+
const userInfoStr = window.sessionStorage.getItem('userDetails');
|
|
2194
|
+
return userInfoStr ? JSON.parse(userInfoStr).filterOwnerHash : undefined;
|
|
2195
|
+
}
|
|
2173
2196
|
getStream(id) {
|
|
2174
2197
|
if (!this.streams[id]) {
|
|
2175
2198
|
this.streams[id] = new BehaviorSubject(this.get(id));
|
|
@@ -2178,6 +2201,7 @@ class FilterService {
|
|
|
2178
2201
|
}
|
|
2179
2202
|
clearSessionAndLocalPersistance(id) {
|
|
2180
2203
|
sessionStorage.removeItem(id);
|
|
2204
|
+
localStorage.removeItem(id);
|
|
2181
2205
|
if (this.filterSettings[id] !== undefined) {
|
|
2182
2206
|
this.filterSettings[id] = null;
|
|
2183
2207
|
}
|
|
@@ -2185,8 +2209,21 @@ class FilterService {
|
|
|
2185
2209
|
this.streams[id].next(null);
|
|
2186
2210
|
}
|
|
2187
2211
|
}
|
|
2212
|
+
persistLocal(setting) {
|
|
2213
|
+
const ownerHash = this.getOwnerHash();
|
|
2214
|
+
if (!ownerHash) {
|
|
2215
|
+
// Without an owner reference, retain selections only in this session.
|
|
2216
|
+
delete setting.ownerHash;
|
|
2217
|
+
this.persistSession(setting);
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2220
|
+
setting.ownerHash = ownerHash;
|
|
2221
|
+
window.localStorage.setItem(setting.id, JSON.stringify(setting));
|
|
2222
|
+
sessionStorage.removeItem(setting.id);
|
|
2223
|
+
}
|
|
2188
2224
|
persistSession(setting) {
|
|
2189
2225
|
sessionStorage.setItem(setting.id, JSON.stringify(setting));
|
|
2226
|
+
localStorage.removeItem(setting.id);
|
|
2190
2227
|
}
|
|
2191
2228
|
persistMemory(setting) {
|
|
2192
2229
|
this.filterSettings[setting.id] = setting;
|
|
@@ -4651,7 +4688,6 @@ class GenericFilterComponent {
|
|
|
4651
4688
|
if (form.valid) {
|
|
4652
4689
|
this._settings = {
|
|
4653
4690
|
id: this.config.id,
|
|
4654
|
-
idamId: this.filterService.getUserId(),
|
|
4655
4691
|
fields: this.getSelectedValues(form.value, this.config)
|
|
4656
4692
|
};
|
|
4657
4693
|
this.cdr.markForCheck();
|