fix i think

This commit is contained in:
ruban 2024-05-03 05:25:11 +00:00
parent 52312dbd23
commit 4cd94370e8

View File

@ -97,18 +97,25 @@ export const useSyncStore = createPersistStore(
const client = this.getClient();
try {
const remoteState = JSON.parse(
const remoteState = await client.get(config.username);
if (!remoteState || remoteState === "") {
console.log("[Sync] Remote state is empty, using local state instead.");
return
} else {
const parsedRemoteState = JSON.parse(
await client.get(config.username),
) as AppState;
mergeAppState(localState, remoteState);
mergeAppState(localState, parsedRemoteState);
setLocalAppState(localState);
}
} catch (e) {
console.log("[Sync] failed to get remote state", e);
throw e;
}
await client.set(config.username, JSON.stringify(localState));
this.markSyncTime();
},