mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-07-25 20:14:55 +02:00
wip
This commit is contained in:
@@ -182,6 +182,7 @@ function normalizePreferences(preferences: PossiblyNonNormalizedPreferencesProfi
|
||||
}
|
||||
|
||||
// 各recordについて、modifiedAtが大きい方を採用する
|
||||
// 引数の参照をmutateしないように注意すること
|
||||
export function mergeProfiles(a: PreferencesProfile, b: PreferencesProfile): PreferencesProfile {
|
||||
const merged = {
|
||||
...a,
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user