Skip to content

Commit a457aca

Browse files
committed
fix(editor): improve document compare
1 parent 10becca commit a457aca

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/app/src/utils/database.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,12 @@ export function isEqual(document1: DatabasePageItem, document2: DatabasePageItem
3636
}
3737
}
3838

39-
if (!isDeepEqual(refineDocumentData(documentData1), refineDocumentData(documentData2))) {
39+
const data1 = refineDocumentData({ ...documentData1, ...meta1 })
40+
const data2 = refineDocumentData({ ...documentData2, ...meta2 })
41+
if (!isDeepEqual(data1, data2)) {
4042
return false
4143
}
4244

43-
if (meta1 && meta2) {
44-
const { __hash__: _hash1, ...metaFields1 } = meta1
45-
const { __hash__: _hash2, ...metaFields2 } = meta2
46-
if (JSON.stringify(metaFields1) !== JSON.stringify(metaFields2)) {
47-
return false
48-
}
49-
}
50-
5145
return true
5246
}
5347

@@ -63,5 +57,11 @@ function refineDocumentData(doc: Record<string, unknown>) {
6357
// documents with same id are being compared, so it is safe to remove `path` and `__hash__`
6458
Reflect.deleteProperty(doc, '__hash__')
6559
Reflect.deleteProperty(doc, 'path')
60+
61+
// default value of navigation is true
62+
if (typeof doc.navigation === 'undefined') {
63+
doc.navigation = true
64+
}
65+
6666
return doc
6767
}

0 commit comments

Comments
 (0)