From 2fecdbc7a7069eb7f0d5023b764968f4a0b1e1de Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 3 Jan 2024 01:24:20 +0530 Subject: [PATCH] refactor: remove unnecessary code and reload data only if at least one dependant column exist Signed-off-by: Pranav C --- packages/nc-gui/composables/useData.ts | 44 ++++++++++---------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/packages/nc-gui/composables/useData.ts b/packages/nc-gui/composables/useData.ts index 5f1d18cf3d..717db76d8e 100644 --- a/packages/nc-gui/composables/useData.ts +++ b/packages/nc-gui/composables/useData.ts @@ -1,5 +1,5 @@ -import { UITypes } from 'nocodb-sdk' import type { ColumnType, LinkToAnotherRecordType, PaginatedType, RelationTypes, TableType, ViewType } from 'nocodb-sdk' +import { UITypes } from 'nocodb-sdk' import type { ComputedRef, Ref } from 'vue' import { NOCO, @@ -376,35 +376,25 @@ export function useData(args: { } for (const row of rows) { - if (!undo) { - /** update row data(to sync formula and other related columns) - * update only formula, rollup and auto updated datetime columns data to avoid overwriting any changes made by user - */ - Object.assign( - row.row, - metaValue!.columns!.reduce>((acc: Record, col: ColumnType) => { - if ( - col.uidt === UITypes.Formula || - col.uidt === UITypes.QrCode || - col.uidt === UITypes.Barcode || - col.uidt === UITypes.Rollup || - col.uidt === UITypes.Checkbox || - col.uidt === UITypes.User || - col.au || - col.cdf?.includes(' on update ') - ) - acc[col.title!] = row.row[col.title!] - return acc - }, {} as Record), - ) - Object.assign(row.oldRow, row.row) - } - if (row.rowMeta) row.rowMeta.saving = false } - // reload data since row update may change the other columns data( formula, QrCode, Barcode, Rollup, Checkbox, User, Auto Updated Datetime, etc...) - await callbacks?.loadData?.() + // reload data since row update may change the other columns data( Formula, QrCode, Barcode, Rollup, Checkbox, User, Auto Updated Datetime, etc...) + if ( + metaValue!.columns!.some((col) => + [ + UITypes.QrCode, + UITypes.LastModifiedTime, + UITypes.Barcode, + UITypes.Formula, + UITypes.Lookup, + UITypes.Rollup, + UITypes.LinkToAnotherRecord, + ].includes(col.uidt), + ) + ) { + await callbacks?.loadData?.() + } await callbacks?.globalCallback?.() }