Skip to content

Commit 1b061eb

Browse files
Simplify SplitsCacheInLocal::setChangeNumber moving clear logic to SplitsCacheInLocal::validateCache
1 parent 8938334 commit 1b061eb

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

src/storages/inLocalStorage/SplitsCacheInLocal.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
1818
private readonly storageHash: string;
1919
private readonly flagSetsFilter: string[];
2020
private hasSync?: boolean;
21-
private updateNewFilter?: boolean;
2221

2322
constructor(settings: ISettings, keys: KeyBuilderCS) {
2423
super();
@@ -47,13 +46,12 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
4746
const storageHash = localStorage.getItem(storageHashKey);
4847

4948
if (storageHash !== this.storageHash) {
49+
this.log.info(LOG_PREFIX + 'SDK key, flags filter criteria or flags spec version was modified. Updating cache');
5050
try {
51-
// mark cache to update the new query filter on first successful splits fetch
52-
this.updateNewFilter = true;
53-
5451
// if there is cache, clear it
5552
if (this.getChangeNumber() > -1) this.clear();
5653

54+
localStorage.setItem(storageHashKey, this.storageHash);
5755
} catch (e) {
5856
this.log.error(LOG_PREFIX + e);
5957
}
@@ -169,19 +167,6 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
169167
}
170168

171169
setChangeNumber(changeNumber: number): boolean {
172-
173-
// when using a new split query, we must update it at the store
174-
if (this.updateNewFilter) {
175-
this.log.info(LOG_PREFIX + 'SDK key, flags filter criteria or flags spec version was modified. Updating cache');
176-
const storageHashKey = this.keys.buildHashKey();
177-
try {
178-
localStorage.setItem(storageHashKey, this.storageHash);
179-
} catch (e) {
180-
this.log.error(LOG_PREFIX + e);
181-
}
182-
this.updateNewFilter = false;
183-
}
184-
185170
try {
186171
localStorage.setItem(this.keys.buildSplitsTillKey(), changeNumber + '');
187172
// update "last updated" timestamp with current time

0 commit comments

Comments
 (0)