MCPcopy
hub / github.com/darkreader/darkreader / loadStateInternal

Method loadStateInternal

src/utils/state-manager-impl.ts:242–267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

240 }
241
242 private loadStateInternal() {
243 this.storage.get(this.localStorageKey, (data: any) => {
244 switch (this.meta) {
245 case StateManagerImplState.INITIAL:
246 case StateManagerImplState.READY:
247 case StateManagerImplState.SAVING:
248 case StateManagerImplState.SAVING_OVERRIDE:
249 this.logWarn('Unexpected state. Possible data race!');
250 return;
251 case StateManagerImplState.LOADING:
252 this.meta = StateManagerImplState.READY;
253 this.applyState(data[this.localStorageKey]);
254 this.releaseBarrier();
255 return;
256 case StateManagerImplState.ONCHANGE_RACE:
257 this.meta = StateManagerImplState.RECOVERY;
258 this.loadStateInternal();
259 // eslint-disable-next-line no-fallthrough
260 case StateManagerImplState.RECOVERY:
261 this.meta = StateManagerImplState.READY;
262 this.applyState(data[this.localStorageKey]);
263 this.releaseBarrier();
264 this.notifyListeners();
265 }
266 });
267 }
268
269 async loadState(): Promise<void> {
270 switch (this.meta) {

Callers 2

saveStateInternalMethod · 0.95
loadStateMethod · 0.95

Calls 4

applyStateMethod · 0.95
releaseBarrierMethod · 0.95
notifyListenersMethod · 0.95
getMethod · 0.65

Tested by

no test coverage detected