debug:mergeAppState list key

This commit is contained in:
cbm 2024-07-13 16:56:28 +08:00
parent bf5546b112
commit e5edfd97a5
2 changed files with 9 additions and 4 deletions

View File

@ -96,7 +96,7 @@ export const useSyncStore = createPersistStore(
const config = get()[provider]; const config = get()[provider];
const client = this.getClient(); const client = this.getClient();
await client.set(config.username, JSON.stringify(localState));
try { try {
const remoteState = await client.get(config.username); const remoteState = await client.get(config.username);
@ -116,6 +116,8 @@ export const useSyncStore = createPersistStore(
throw e; throw e;
} }
await client.set(config.username, JSON.stringify(localState));
this.markSyncTime(); this.markSyncTime();

View File

@ -137,9 +137,12 @@ export function setLocalAppState(appState: AppState) {
export function mergeAppState(localState: AppState, remoteState: AppState) { export function mergeAppState(localState: AppState, remoteState: AppState) {
Object.keys(localState).forEach(<T extends keyof AppState>(k: string) => { Object.keys(localState).forEach(<T extends keyof AppState>(k: string) => {
const key = k as T; const key = k as T;
//if(k !== ''){
console.log('mergeAppState',k)
const localStoreState = localState[key]; const localStoreState = localState[key];
const remoteStoreState = remoteState[key]; const remoteStoreState = remoteState[key];
MergeStates[key](localStoreState, remoteStoreState); MergeStates[key](localStoreState, remoteStoreState);
//}
}); });
return localState; return localState;