|
@@ -1,5 +1,4 @@
|
|
|
import { getClientConfig } from "../config/client";
|
|
import { getClientConfig } from "../config/client";
|
|
|
-import { Updater } from "../typing";
|
|
|
|
|
import { ApiPath, STORAGE_KEY, StoreKey } from "../constant";
|
|
import { ApiPath, STORAGE_KEY, StoreKey } from "../constant";
|
|
|
import { createPersistStore } from "../utils/store";
|
|
import { createPersistStore } from "../utils/store";
|
|
|
import {
|
|
import {
|
|
@@ -100,15 +99,17 @@ export const useSyncStore = createPersistStore(
|
|
|
const remoteState = await client.get(config.username);
|
|
const remoteState = await client.get(config.username);
|
|
|
if (!remoteState || remoteState === "") {
|
|
if (!remoteState || remoteState === "") {
|
|
|
await client.set(config.username, JSON.stringify(localState));
|
|
await client.set(config.username, JSON.stringify(localState));
|
|
|
- console.log("[Sync] Remote state is empty, using local state instead.");
|
|
|
|
|
- return
|
|
|
|
|
|
|
+ console.log(
|
|
|
|
|
+ "[Sync] Remote state is empty, using local state instead.",
|
|
|
|
|
+ );
|
|
|
|
|
+ return;
|
|
|
} else {
|
|
} else {
|
|
|
const parsedRemoteState = JSON.parse(
|
|
const parsedRemoteState = JSON.parse(
|
|
|
await client.get(config.username),
|
|
await client.get(config.username),
|
|
|
) as AppState;
|
|
) as AppState;
|
|
|
mergeAppState(localState, parsedRemoteState);
|
|
mergeAppState(localState, parsedRemoteState);
|
|
|
setLocalAppState(localState);
|
|
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;
|