@hmcts/rpx-xui-common-lib 3.2.17-exui-4454-2 → 3.2.17-tar-upscale

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.
@@ -2152,6 +2152,8 @@ class FilterService {
2152
2152
  persist(setting, persistence) {
2153
2153
  switch (persistence) {
2154
2154
  case 'local':
2155
+ this.persistLocal(setting);
2156
+ break;
2155
2157
  case 'session':
2156
2158
  this.persistSession(setting);
2157
2159
  break;
@@ -2165,12 +2167,23 @@ class FilterService {
2165
2167
  if (this.filterSettings[id]) {
2166
2168
  return this.filterSettings[id];
2167
2169
  }
2168
- const storedSetting = sessionStorage.getItem(id);
2169
- if (storedSetting) {
2170
- return JSON.parse(storedSetting);
2170
+ if (sessionStorage.getItem(id)) {
2171
+ return JSON.parse(sessionStorage.getItem(id));
2172
+ }
2173
+ if (localStorage.getItem(id)) {
2174
+ if (this.isSameUser(id)) {
2175
+ return JSON.parse(window.localStorage.getItem(id));
2176
+ }
2177
+ else {
2178
+ return null;
2179
+ }
2171
2180
  }
2172
2181
  return null;
2173
2182
  }
2183
+ isSameUser(id) {
2184
+ const filterSetting = JSON.parse(window.localStorage.getItem(id));
2185
+ return !!filterSetting.idamId && filterSetting.idamId === this.getUserId();
2186
+ }
2174
2187
  getStream(id) {
2175
2188
  if (!this.streams[id]) {
2176
2189
  this.streams[id] = new BehaviorSubject(this.get(id));
@@ -2179,6 +2192,7 @@ class FilterService {
2179
2192
  }
2180
2193
  clearSessionAndLocalPersistance(id) {
2181
2194
  sessionStorage.removeItem(id);
2195
+ localStorage.removeItem(id);
2182
2196
  if (this.filterSettings[id] !== undefined) {
2183
2197
  this.filterSettings[id] = null;
2184
2198
  }
@@ -2186,6 +2200,10 @@ class FilterService {
2186
2200
  this.streams[id].next(null);
2187
2201
  }
2188
2202
  }
2203
+ persistLocal(setting) {
2204
+ setting.idamId = this.getUserId();
2205
+ window.localStorage.setItem(setting.id, JSON.stringify(setting));
2206
+ }
2189
2207
  persistSession(setting) {
2190
2208
  sessionStorage.setItem(setting.id, JSON.stringify(setting));
2191
2209
  }