From 3bdcbb8e9877e4d7caa3db539c755896fb8542d7 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sun, 11 Sep 2022 00:29:59 +0530 Subject: [PATCH] fix(gui): sync LTAR data on switching tab Signed-off-by: Pranav C --- .../nc-gui/components/smartsheet/Grid.vue | 23 +++++++++++-------- packages/nc-gui/components/smartsheet/Row.vue | 4 ++++ packages/nc-gui/composables/useViewData.ts | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/Grid.vue b/packages/nc-gui/components/smartsheet/Grid.vue index a12247c475..f8faa99b39 100644 --- a/packages/nc-gui/components/smartsheet/Grid.vue +++ b/packages/nc-gui/components/smartsheet/Grid.vue @@ -324,19 +324,24 @@ const showContextMenu = (e: MouseEvent, target?: { row: number; col: number }) = } } +const rowRefs = $ref() + onBeforeUnmount(async () => { - for (const row of data.value) { - if (row.rowMeta.new) { - await updateOrSaveRow(row, null) - row.rowMeta.changed = false + console.log(rowRefs) + for (const [index, currentRow] of Object.entries(data.value)) { + if (currentRow.rowMeta.new) { + const syncLTARRefs = rowRefs[index]!.syncLTARRefs + const savedRow = await updateOrSaveRow(currentRow, null) + await syncLTARRefs(savedRow) + currentRow.rowMeta.changed = false continue } - if (row.rowMeta.changed) { - row.rowMeta.changed = false + if (currentRow.rowMeta.changed) { + currentRow.rowMeta.changed = false for (const field of meta?.value.columns ?? []) { if (isVirtualCol(field)) continue - if (row.row[field.title!] !== row.oldRow[field.title!]) { - await updateOrSaveRow(row, field.title!) + if (currentRow.row[field.title!] !== currentRow.oldRow[field.title!]) { + await updateOrSaveRow(currentRow, field.title!) } } } @@ -418,7 +423,7 @@ onBeforeUnmount(async () => { - +