Merge pull request #92 from ChatGPTNextWeb/main

merge
This commit is contained in:
sijinhui 2024-05-13 13:40:56 +08:00 committed by GitHub
commit e1de919769
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -97,11 +97,18 @@ export const useSyncStore = createPersistStore(
const client = this.getClient();
try {
const remoteState = JSON.parse(
const remoteState = await client.get(config.username);
if (!remoteState || remoteState === "") {
await client.set(config.username, JSON.stringify(localState));
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;