mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-19 20:20:16 +09:00
fix i think
This commit is contained in:
parent
52312dbd23
commit
4cd94370e8
@ -95,22 +95,29 @@ export const useSyncStore = createPersistStore(
|
|||||||
const provider = get().provider;
|
const provider = get().provider;
|
||||||
const config = get()[provider];
|
const config = get()[provider];
|
||||||
const client = this.getClient();
|
const client = this.getClient();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const remoteState = JSON.parse(
|
const remoteState = await client.get(config.username);
|
||||||
await client.get(config.username),
|
if (!remoteState || remoteState === "") {
|
||||||
) as AppState;
|
console.log("[Sync] Remote state is empty, using local state instead.");
|
||||||
mergeAppState(localState, remoteState);
|
return
|
||||||
setLocalAppState(localState);
|
} else {
|
||||||
|
const parsedRemoteState = JSON.parse(
|
||||||
|
await client.get(config.username),
|
||||||
|
) as AppState;
|
||||||
|
|
||||||
|
mergeAppState(localState, parsedRemoteState);
|
||||||
|
setLocalAppState(localState);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("[Sync] failed to get remote state", e);
|
console.log("[Sync] failed to get remote state", e);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
await client.set(config.username, JSON.stringify(localState));
|
await client.set(config.username, JSON.stringify(localState));
|
||||||
|
|
||||||
this.markSyncTime();
|
this.markSyncTime();
|
||||||
},
|
},
|
||||||
|
|
||||||
async check() {
|
async check() {
|
||||||
const client = this.getClient();
|
const client = this.getClient();
|
||||||
|
Loading…
Reference in New Issue
Block a user