Browse Source

fix: keep any local state value of filter after sync

pull/8732/head
Pranav C 6 months ago
parent
commit
a2b81dc73c
  1. 28
      packages/nc-gui/composables/useViewFilters.ts

28
packages/nc-gui/composables/useViewFilters.ts

@ -401,22 +401,26 @@ export function useViewFilters(
})
} else {
if (linkColId?.value) {
// set value with current value of filter since user can change value while saving
const savedFilter = await $api.dbTableLinkFilter.create(linkColId.value, {
...filter,
fk_parent_id: parentId,
})
// override any local changes with saved filter since user can change value while saving
filters.value[i] = {
...((await $api.dbTableLinkFilter.create(linkColId.value, {
...filter,
fk_parent_id: parentId,
})) || {}),
value: (filters.value[i] || filter).value,
...(savedFilter || {}),
...filters.value[i],
status: undefined,
}
} else {
// set value with current value of filter since user can change value while saving
const savedFilter = await $api.dbTableFilter.create(view.value.id!, {
...filter,
fk_parent_id: parentId.value,
})
// override any local changes with saved filter since user can change value while saving
filters.value[i] = {
...((await $api.dbTableFilter.create(view.value.id!, {
...filter,
fk_parent_id: parentId.value,
})) || {}),
value: (filters.value[i] || filter).value,
...(savedFilter || {}),
...filters.value[i],
status: undefined,
}
}
if (!isLink && !isWebhook) allFilters.value.push(filters.value[+i])

Loading…
Cancel
Save