Browse Source

fix: avoid overlapped reload of bases

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3573/head
mertmit 2 years ago
parent
commit
fb8c1b698a
  1. 8
      packages/nc-gui/components/dashboard/settings/DataSources.vue

8
packages/nc-gui/components/dashboard/settings/DataSources.vue

@ -28,21 +28,23 @@ let sources = $ref<BaseType[]>([])
let activeBaseId = $ref('') let activeBaseId = $ref('')
let metadiffbases = $ref<string[]>([]) let metadiffbases = $ref<string[]>([])
let clientType = $ref<ClientType>(ClientType.MYSQL) let clientType = $ref<ClientType>(ClientType.MYSQL)
let isReloading = $ref(false)
async function loadBases() { async function loadBases() {
try { try {
if (!project.value?.id) return if (!project.value?.id) return
isReloading = true
vReload.value = true vReload.value = true
const baseList = await $api.base.list(project.value?.id) const baseList = await $api.base.list(project.value?.id)
if (baseList.bases.list && baseList.bases.list.length) { if (baseList.bases.list && baseList.bases.list.length) {
sources = baseList.bases.list sources = baseList.bases.list
} }
loadMetaDiff()
} catch (e) { } catch (e) {
console.error(e) console.error(e)
} finally { } finally {
vReload.value = false vReload.value = false
isReloading = false
} }
} }
@ -138,14 +140,16 @@ const moveBase = async (e: any) => {
onMounted(async () => { onMounted(async () => {
if (sources.length === 0) { if (sources.length === 0) {
await loadBases() await loadBases()
await loadMetaDiff()
} }
}) })
watch( watch(
() => props.reload, () => props.reload,
async (reload) => { async (reload) => {
if (reload) { if (reload && !isReloading) {
await loadBases() await loadBases()
await loadMetaDiff()
} }
}, },
) )

Loading…
Cancel
Save