mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-06 08:38:37 +00:00
fix(mobx): ignore lack of sync object
This commit is contained in:
@@ -123,6 +123,7 @@ export default class State {
|
|||||||
() => stringify(store.toJSON()),
|
() => stringify(store.toJSON()),
|
||||||
async (value) => {
|
async (value) => {
|
||||||
try {
|
try {
|
||||||
|
console.log(`I am saving ${id} as ${value}`);
|
||||||
await localforage.setItem(id, JSON.parse(value));
|
await localforage.setItem(id, JSON.parse(value));
|
||||||
if (id === "sync") return;
|
if (id === "sync") return;
|
||||||
if (!client) return;
|
if (!client) return;
|
||||||
@@ -217,14 +218,12 @@ export default class State {
|
|||||||
|
|
||||||
// Load MobX store.
|
// Load MobX store.
|
||||||
const sync = (await localforage.getItem("sync")) as DataSync;
|
const sync = (await localforage.getItem("sync")) as DataSync;
|
||||||
if (sync) {
|
const { revision } = sync ?? { revision: {} };
|
||||||
const { revision } = sync;
|
for (const [id, store] of this.persistent) {
|
||||||
for (const [id, store] of this.persistent) {
|
if (id === "sync") continue;
|
||||||
if (id === "sync") continue;
|
const data = await localforage.getItem(id);
|
||||||
const data = await localforage.getItem(id);
|
if (typeof data === "object" && data !== null) {
|
||||||
if (typeof data === "object" && data !== null) {
|
store.hydrate(data, revision[id] ?? +new Date());
|
||||||
store.hydrate(data, revision[id]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user