Browse Source

refactor(gui): use `until` to only listen until loads tables

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3708/head
Pranav C 2 years ago
parent
commit
d25954055c
  1. 22
      packages/nc-gui/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue

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

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { TabItem } from '~/composables' import type { TabItem } from '~/composables'
import { TabMetaInj, watchOnce } from '#imports' import { TabMetaInj, until } from '#imports'
const { getMeta } = useMetas() const { getMeta } = useMetas()
@ -15,20 +15,12 @@ const activeTab = inject(
computed(() => ({} as TabItem)), computed(() => ({} as TabItem)),
) )
if (tables.value.length) { /** wait until table list loads since meta load requires table list **/
getMeta(route.params.title as string, true).finally(() => (loading.value = false)) until(tables)
loading.value = false .toMatch((tables) => tables.length > 0)
} else { .then(() => {
/** wait until table list loads since meta load requires table list **/ getMeta(route.params.title as string, true).finally(() => (loading.value = false))
watchOnce( })
() => tables.value.length,
(nextVal) => {
if (!nextVal) return
getMeta(route.params.title as string, true).finally(() => (loading.value = false))
loading.value = false
},
)
}
</script> </script>
<template> <template>

Loading…
Cancel
Save