Browse Source

feat: clear project state on scope dispose

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3368/head
mertmit 2 years ago
parent
commit
e44b01e722
  1. 11
      packages/nc-gui-v2/composables/useProject.ts

11
packages/nc-gui-v2/composables/useProject.ts

@ -17,6 +17,7 @@ export function useProject(projectId?: MaybeRef<string>) {
const projectMetaInfo = useState<ProjectMetaInfo | undefined>('projectMetaInfo')
// todo: refactor path param name and variable name
const projectType = $computed(() => route.params.projectType as string)
const isLoaded = ref(false)
const projectBaseType = $computed(() => project.value?.bases?.[0]?.type || '')
const isMysql = computed(() => ['mysql', 'mysql2'].includes(projectBaseType))
@ -71,6 +72,7 @@ export function useProject(projectId?: MaybeRef<string>) {
} else {
_projectId = route.params.projectId as string
}
isLoaded.value = true
project.value = await $api.project.read(_projectId!)
await loadProjectRoles()
await loadTables()
@ -94,7 +96,16 @@ export function useProject(projectId?: MaybeRef<string>) {
} catch (e) {
return {}
}
})
onScopeDispose(() => {
if (isLoaded.value === true) {
project.value = {}
tables.value = []
projectMetaInfo.value = undefined
projectRoles.value = {}
}
})
return {
project,

Loading…
Cancel
Save