Browse Source

fix(nc-gui): triggering multiple times cmd palette api issue

pull/7490/head
Ramesh Mane 6 months ago
parent
commit
6146f2d7d9
  1. 8
      packages/nc-gui/app.vue
  2. 4
      packages/nc-gui/components/workspace/CreateProjectDlg.vue
  3. 7
      packages/nc-gui/composables/useCommandPalette/index.ts

8
packages/nc-gui/app.vue

@ -13,7 +13,7 @@ const disableBaseLayout = computed(() => route.value.path.startsWith('/nc/view')
useTheme()
const { commandPalette, cmdData, cmdPlaceholder, activeScope, loadTemporaryScope } = useCommandPalette()
const { commandPalette, cmdData, cmdPlaceholder, activeScope, loadTemporaryScope, refreshCommandPalette } = useCommandPalette()
applyNonSelectable()
useEventListener(document, 'keydown', async (e: KeyboardEvent) => {
@ -79,6 +79,12 @@ function setActiveCmdView(cmd: CommandPaletteType) {
cmdK.value = false
}
}
onMounted(() => {
nextTick(() => {
refreshCommandPalette()
})
})
</script>
<template>

4
packages/nc-gui/components/workspace/CreateProjectDlg.vue

@ -19,10 +19,13 @@ const dialogShow = useVModel(props, 'modelValue', emit)
const baseType = computed(() => props.type ?? NcProjectType.DB)
const basesStore = useBases()
const { createProject: _createProject } = basesStore
const { navigateToProject } = useGlobal()
const { refreshCommandPalette } = useCommandPalette()
const nameValidationRules = [
{
required: true,
@ -59,6 +62,7 @@ const createProject = async () => {
setTimeout(() => {
creating.value = false
}, 500)
refreshCommandPalette()
}
}

7
packages/nc-gui/composables/useCommandPalette/index.ts

@ -148,23 +148,26 @@ export const useCommandPalette = createSharedComposable(() => {
if (route.value.params.typeOrId === 'base') {
if (activeScope.value.scope === 'disabled') return
activeScope.value = { scope: 'disabled', data: {} }
loadScope()
} else if (route.value.params.typeOrId === 'nc') {
if (activeScope.value.data.base_id === route.value.params.baseId) return
activeScope.value = {
scope: `p-${route.value.params.baseId}`,
data: {},
data: { base_id: route.value.params.baseId },
}
loadScope()
}
} else {
if (route.value.path.startsWith('/account')) {
if (activeScope.value.scope === 'account_settings') return
activeScope.value = { scope: 'account_settings', data: {} }
loadScope()
} else {
if (activeScope.value.scope === 'root') return
activeScope.value = { scope: 'root', data: {} }
loadScope()
}
}

Loading…
Cancel
Save