Skip to content

Commit a126917

Browse files
committed
fix: implement syncPoints caching in SettingPanel to prevent data loss on reconnection
1 parent c7accaf commit a126917

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎packages/dag/src/components/migration/SettingPanel.vue‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ const sourceNodes = computed(() => {
309309
}))
310310
})
311311
312+
// 缓存所有历史 syncPoint 设置,防止断线重连后丢失
313+
const syncPointsCache: Record<string, any> = {}
314+
312315
const systemTimeZone = computed(() => {
313316
const timeZone = new Date().getTimezoneOffset() / 60
314317
let systemTimeZone = ''
@@ -502,15 +505,17 @@ watch(
502505
503506
watch(sourceNodes, () => {
504507
const timeZone = systemTimeZone.value
505-
const oldPoints = props.settings.syncPoints
506-
const oldPointsMap = oldPoints?.length
507-
? oldPoints.reduce((map: Record<string, any>, point: any) => {
508-
if (point.nodeId) map[point.nodeId] = point
509-
return map
510-
}, {})
511-
: {}
508+
509+
if (props.settings.syncPoints?.length) {
510+
props.settings.syncPoints.forEach((point: any) => {
511+
if (point.nodeId) {
512+
syncPointsCache[point.nodeId] = point
513+
}
514+
})
515+
}
516+
512517
const syncPoints = sourceNodes.value.map((item: any) => {
513-
const old = oldPointsMap[item.nodeId]
518+
const old = syncPointsCache[item.nodeId]
514519
const point = {
515520
...item,
516521
timeZone,

0 commit comments

Comments
 (0)