Browse Source

fix: if cancelled error skip it cancelled to avoid unnecessary call

pull/7218/head
Pranav C 1 year ago committed by Ramesh Mane
parent
commit
8c29e39e34
  1. 42
      packages/nc-gui/composables/useViewData.ts

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

@ -187,24 +187,32 @@ export function useViewData(
controller.value = CancelToken.source() controller.value = CancelToken.source()
isPaginationLoading.value = true isPaginationLoading.value = true
let response
const response = !isPublic.value try {
? await api.dbViewRow.list( response = !isPublic.value
'noco', ? await api.dbViewRow.list(
base.value.id!, 'noco',
metaId.value!, base.value.id!,
viewMeta.value!.id!, metaId.value!,
{ viewMeta.value!.id!,
...queryParams.value, {
...params, ...queryParams.value,
...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }), ...params,
...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }), ...(isUIAllowed('sortSync') ? {} : { sortArrJson: JSON.stringify(sorts.value) }),
where: where?.value, ...(isUIAllowed('filterSync') ? {} : { filterArrJson: JSON.stringify(nestedFilters.value) }),
} as any, where: where?.value,
{ cancelToken: controller.value.token }, } as any,
) { cancelToken: controller.value.token },
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value }) )
: await fetchSharedViewData({ sortsArr: sorts.value, filtersArr: nestedFilters.value })
} catch (error) {
// if the request is canceled, then do nothing
if (error.code === 'ERR_CANCELED') {
return
}
throw error
}
formattedData.value = formatData(response.list) formattedData.value = formatData(response.list)
paginationData.value = response.pageInfo paginationData.value = response.pageInfo
isPaginationLoading.value = false isPaginationLoading.value = false

Loading…
Cancel
Save