Browse Source

fix(gui): wait until inserting record to avoid duplicate row insertion

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4088/head
Pranav C 2 years ago
parent
commit
507780a098
  1. 2
      packages/nc-gui/components/smartsheet/Grid.vue
  2. 8
      packages/nc-gui/composables/useViewData.ts
  3. 2
      packages/nc-gui/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue

2
packages/nc-gui/components/smartsheet/Grid.vue

@ -705,7 +705,7 @@ watch(
.nc-expand {
&:not(.nc-comment) {
//@apply hidden;
@apply hidden;
}
&.nc-comment {

8
packages/nc-gui/composables/useViewData.ts

@ -11,6 +11,7 @@ import {
message,
populateInsertObject,
ref,
until,
useApi,
useGlobal,
useI18n,
@ -224,8 +225,8 @@ export function useViewData(
insertObj,
)
formattedData.value?.splice(rowIndex ?? 0, 1, {
row: insertedData,
Object.assign(formattedData.value[rowIndex], {
row: { ...insertedData, ...row },
rowMeta: { ...row.rowMeta, new: undefined },
oldRow: { ...insertedData },
})
@ -287,6 +288,9 @@ export function useViewData(
ltarState?: Record<string, any>,
args: { metaValue?: TableType; viewMetaValue?: ViewType } = {},
) {
// if new row and save is in progress then wait until the save is complete
await until(() => !(row.rowMeta.new && row.rowMeta.saving)).toMatch((v) => v)
if (row.rowMeta.new) {
return await insertRow(row.row, formattedData.value.indexOf(row), ltarState, args)
} else {

2
packages/nc-gui/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue

@ -32,7 +32,7 @@ watch(
<template>
<div class="w-full h-full relative">
<LazyTabsSmartsheet :active-tab="activeTab"/>
<LazyTabsSmartsheet :active-tab="activeTab" />
<general-overlay :model-value="loading" inline transition class="!bg-opacity-15">
<div class="flex items-center justify-center h-full w-full !bg-white !bg-opacity-85 z-1000">

Loading…
Cancel
Save