@@ -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 /**
2423 * @param {KeyBuilderCS } keys
@@ -102,39 +101,29 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
102101 }
103102
104103 addSplit ( name : string , split : ISplit ) {
105- try {
106- const splitKey = this . keys . buildSplitKey ( name ) ;
107- const splitFromLocalStorage = localStorage . getItem ( splitKey ) ;
108- const previousSplit = splitFromLocalStorage ? JSON . parse ( splitFromLocalStorage ) : null ;
104+ const splitKey = this . keys . buildSplitKey ( name ) ;
105+ const splitFromLocalStorage = localStorage . getItem ( splitKey ) ;
106+ const previousSplit = splitFromLocalStorage ? JSON . parse ( splitFromLocalStorage ) : null ;
109107
110- localStorage . setItem ( splitKey , JSON . stringify ( split ) ) ;
108+ localStorage . setItem ( splitKey , JSON . stringify ( split ) ) ;
111109
112- this . _incrementCounts ( split ) ;
113- this . _decrementCounts ( previousSplit ) ;
110+ this . _incrementCounts ( split ) ;
111+ this . _decrementCounts ( previousSplit ) ;
114112
115- // if (previousSplit) this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
116- // this.addToFlagSets(split);
113+ // if (previousSplit) this.removeFromFlagSets(previousSplit.name, previousSplit.sets);
114+ // this.addToFlagSets(split);
117115
118- return true ;
119- } catch ( e ) {
120- this . log . error ( LOG_PREFIX + e ) ;
121- return false ;
122- }
116+ return true ;
123117 }
124118
125119 removeSplit ( name : string ) : boolean {
126- try {
127- const split = this . getSplit ( name ) ;
128- localStorage . removeItem ( this . keys . buildSplitKey ( name ) ) ;
120+ const split = this . getSplit ( name ) ;
121+ localStorage . removeItem ( this . keys . buildSplitKey ( name ) ) ;
129122
130- this . _decrementCounts ( split ) ;
131- // if (split) this.removeFromFlagSets(split.name, split.sets);
123+ this . _decrementCounts ( split ) ;
124+ // if (split) this.removeFromFlagSets(split.name, split.sets);
132125
133- return true ;
134- } catch ( e ) {
135- this . log . error ( LOG_PREFIX + e ) ;
136- return false ;
137- }
126+ return true ;
138127 }
139128
140129 getSplit ( name : string ) {
@@ -143,19 +132,6 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
143132 }
144133
145134 setChangeNumber ( changeNumber : number ) : boolean {
146-
147- // when using a new split query, we must update it at the store
148- if ( this . updateNewFilter ) {
149- this . log . info ( LOG_PREFIX + 'SDK key, flags filter criteria or flags spec version was modified. Updating cache' ) ;
150- const storageHashKey = this . keys . buildHashKey ( ) ;
151- try {
152- localStorage . setItem ( storageHashKey , this . storageHash ) ;
153- } catch ( e ) {
154- this . log . error ( LOG_PREFIX + e ) ;
155- }
156- this . updateNewFilter = false ;
157- }
158-
159135 try {
160136 localStorage . setItem ( this . keys . buildSplitsTillKey ( ) , changeNumber + '' ) ;
161137 // update "last updated" timestamp with current time
@@ -246,12 +222,12 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
246222
247223 if ( storageHash !== this . storageHash ) {
248224 try {
249- // mark cache to update the new query filter on first successful splits fetch
250- this . updateNewFilter = true ;
251-
252225 // if there is cache, clear it
253226 if ( this . checkCache ( ) ) this . clear ( ) ;
254227
228+ this . log . info ( LOG_PREFIX + 'SDK key, flags filter criteria or flags spec version was modified. Updating cache' ) ;
229+ localStorage . setItem ( storageHashKey , this . storageHash ) ;
230+
255231 } catch ( e ) {
256232 this . log . error ( LOG_PREFIX + e ) ;
257233 }
0 commit comments