47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
// Metro module 1220 (f1221).
|
|
import Module589 from "../_bundle/Module589";
|
|
import Dispatcher from "../Dispatcher";
|
|
import Module38 from "../_bundle/Module38";
|
|
import { Storage } from "../_bundle/Module595";
|
|
class MobileCacheSnapshotStore extends Module589.Store {
|
|
static allStores = [];
|
|
constructor(a0, a1) {
|
|
const r10 = {
|
|
...a0,
|
|
CLEAR_CACHES: () => {
|
|
this.clear();
|
|
return false;
|
|
},
|
|
WRITE_CACHES: () => {
|
|
this.save();
|
|
return false;
|
|
}
|
|
};
|
|
super(Dispatcher, r10, a1);
|
|
Module38(this.getClass().displayName != null, "Snapshot stores need a display name");
|
|
Module38(!("CLEAR_CACHES" in a0), "MobileCacheSnapshotStores cannot use the 'CLEAR_CACHES' action");
|
|
Module38(!("WRITE_CACHES" in a0), "MobileCacheSnapshotStores cannot use the 'WRITE_CACHES' action");
|
|
MobileCacheSnapshotStore.allStores.push(this);
|
|
}
|
|
static clearAll() {
|
|
MobileCacheSnapshotStore.allStores.forEach((allStore) => allStore.clear());
|
|
}
|
|
get persistKey() {
|
|
return `${this.getClass().displayName}-snapshot`;
|
|
}
|
|
clear() {
|
|
Storage.remove(this.persistKey);
|
|
}
|
|
save() {
|
|
Storage.set(this.persistKey, this.takeSnapshot());
|
|
}
|
|
readSnapshot(a0) {
|
|
const r12 = Storage.get(this.persistKey);
|
|
return r12 == null ? null : r12.version === a0 ? r12.data : null;
|
|
}
|
|
getClass() {
|
|
return this.constructor;
|
|
}
|
|
}
|
|
export default MobileCacheSnapshotStore;
|