From 66498639bf18ecaa45d6455458e621a29d606ec0 Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Sat, 25 Jul 2026 19:13:46 +0900 Subject: [PATCH] wip --- packages/frontend/src/preferences/manager.ts | 1 + packages/frontend/src/preferences/utility.ts | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/preferences/manager.ts b/packages/frontend/src/preferences/manager.ts index 4b1ff1c3f3..4f33993800 100644 --- a/packages/frontend/src/preferences/manager.ts +++ b/packages/frontend/src/preferences/manager.ts @@ -182,6 +182,7 @@ function normalizePreferences(preferences: PossiblyNonNormalizedPreferencesProfi } // 各recordについて、modifiedAtが大きい方を採用する +// 引数の参照をmutateしないように注意すること export function mergeProfiles(a: PreferencesProfile, b: PreferencesProfile): PreferencesProfile { const merged = { ...a, diff --git a/packages/frontend/src/preferences/utility.ts b/packages/frontend/src/preferences/utility.ts index d0791271f0..0c6e6631f1 100644 --- a/packages/frontend/src/preferences/utility.ts +++ b/packages/frontend/src/preferences/utility.ts @@ -163,14 +163,14 @@ export async function cloudSync() { key: prefer.profile.name, }) as PreferencesProfile | null; - if (cloudProfile == null || cloudProfile.modifiedAt <= prefer.profile.modifiedAt) { - if (_DEV_) console.log('no new cloud profile found, skipping sync'); + if (cloudProfile == null) { + if (_DEV_) console.log('no backuped profile found, skipping sync'); return; } - if (_DEV_) console.log('new cloud profile found, restoring from cloud', cloudProfile); + if (_DEV_) console.log('backuped profile found, syncing', cloudProfile); - miLocalStorage.setItem('preferences', JSON.stringify(cloudProfile)); + miLocalStorage.setItem('preferences', JSON.stringify(mergeProfiles(prefer.profile, cloudProfile))); prefer.reloadProfile(); }