mirror of
https://github.com/paricafe/misskey.git
synced 2025-03-23 11:39:25 -05:00
enhance(frontend): suppress needless confirmation when turn on pref sync
This commit is contained in:
parent
3129fcf164
commit
a06b9eefaa
2 changed files with 31 additions and 1 deletions
packages/frontend/src
|
@ -13,6 +13,7 @@ import { $i } from '@/account.js';
|
|||
import { copyToClipboard } from '@/utility/copy-to-clipboard.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import * as os from '@/os.js';
|
||||
import { deepEqual } from '@/utility/deep-equal.js';
|
||||
|
||||
// NOTE: 明示的な設定値のひとつとして null もあり得るため、設定が存在しないかどうかを判定する目的で null で比較したり ?? を使ってはいけない
|
||||
|
||||
|
@ -340,7 +341,7 @@ export class ProfileManager {
|
|||
const record = this.getMatchedRecordOf(key);
|
||||
|
||||
const existing = await this.storageProvider.cloudGet({ key, cond: record[0] });
|
||||
if (existing != null) {
|
||||
if (existing != null && !deepEqual(existing.value, record[1])) {
|
||||
const { canceled, result } = await os.select({
|
||||
title: i18n.ts.preferenceSyncConflictTitle,
|
||||
text: i18n.ts.preferenceSyncConflictText,
|
||||
|
|
29
packages/frontend/src/utility/deep-equal.ts
Normal file
29
packages/frontend/src/utility/deep-equal.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export function deepEqual(a: any, b: any): boolean {
|
||||
if (a === b) return true;
|
||||
|
||||
if (a === null) return b === null;
|
||||
|
||||
if (Array.isArray(a) && Array.isArray(b)) {
|
||||
if (a.length !== b.length) return false;
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (!deepEqual(a[i], b[i])) return false;
|
||||
}
|
||||
return true;
|
||||
} else if (((typeof a) === 'object') && ((typeof b) === 'object')) {
|
||||
const aks = Object.keys(a);
|
||||
const bks = Object.keys(b);
|
||||
if (aks.length !== bks.length) return false;
|
||||
for (let i = 0; i < aks.length; i++) {
|
||||
const k = aks[i];
|
||||
if (!deepEqual(a[k], b[k])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
Loading…
Add table
Reference in a new issue