From d8485196af2087e7cfed30769a97136a80e2fdee Mon Sep 17 00:00:00 2001 From: mertmit Date: Wed, 13 Dec 2023 18:13:32 +0300 Subject: [PATCH] fix: use basesUser state for getting user count Signed-off-by: mertmit --- .../nc-gui/components/account/UsersModal.vue | 4 +++ packages/nc-gui/components/project/View.vue | 35 +++---------------- packages/nc-gui/store/bases.ts | 3 -- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/packages/nc-gui/components/account/UsersModal.vue b/packages/nc-gui/components/account/UsersModal.vue index 1d6f6fd055..096dc3761b 100644 --- a/packages/nc-gui/components/account/UsersModal.vue +++ b/packages/nc-gui/components/account/UsersModal.vue @@ -34,6 +34,8 @@ const { copy } = useCopy() const { dashboardUrl } = useDashboard() +const { clearBasesUser } = useBases() + const usersData = ref({ emails: '', role: OrgUserRoles.VIEWER, invitationToken: undefined }) const formRef = ref() @@ -64,6 +66,8 @@ const saveUser = async () => { // Successfully updated the user details message.success(t('msg.success.userAdded')) + + clearBasesUser() } catch (e: any) { console.error(e) message.error(await extractSdkResponseErrorMsg(e)) diff --git a/packages/nc-gui/components/project/View.vue b/packages/nc-gui/components/project/View.vue index 15aa847b0a..5ecfe7182a 100644 --- a/packages/nc-gui/components/project/View.vue +++ b/packages/nc-gui/components/project/View.vue @@ -5,9 +5,7 @@ import { isEeUI } from '#imports' const basesStore = useBases() -const { getBaseUsers } = basesStore - -const { openedProject, activeProjectId, baseUserCount } = storeToRefs(basesStore) +const { openedProject, activeProjectId, basesUser } = storeToRefs(basesStore) const { activeTables } = storeToRefs(useTablesStore()) const { activeWorkspace, workspaceUserCount } = storeToRefs(useWorkspace()) @@ -32,24 +30,9 @@ const { isMobileMode } = useGlobal() const baseSettingsState = ref('') -const userCount = isEeUI ? workspaceUserCount : baseUserCount - -const updateBaseUserCount = async () => { - if (!baseUserCount || !isUIAllowed('newUser')) return - - try { - const { totalRows } = await getBaseUsers({ - baseId: activeProjectId.value!, - page: 1, - searchText: undefined, - limit: 20, - }) - - baseUserCount.value = totalRows - } catch (e: any) { - message.error(await extractSdkResponseErrorMsg(e)) - } -} +const userCount = computed(() => + isEeUI ? workspaceUserCount : activeProjectId.value ? basesUser.value.get(activeProjectId.value)?.length : 0, +) watch( () => route.value.query?.page, @@ -82,16 +65,6 @@ watch(projectPageTab, () => { } }) -watch( - () => route.value.params.baseId, - (newVal, oldVal) => { - if (newVal && oldVal === undefined) { - updateBaseUserCount() - } - }, - { immediate: true }, -) - watch( () => openedProject.value?.title, () => { diff --git a/packages/nc-gui/store/bases.ts b/packages/nc-gui/store/bases.ts index 3e35306d13..4f3e82a3e5 100644 --- a/packages/nc-gui/store/bases.ts +++ b/packages/nc-gui/store/bases.ts @@ -14,8 +14,6 @@ export const useBases = defineStore('basesStore', () => { const basesList = computed(() => Array.from(bases.value.values()).sort((a, b) => a.updated_at - b.updated_at)) const basesUser = ref>(new Map()) - const baseUserCount = ref(undefined) - const router = useRouter() const route = router.currentRoute @@ -299,7 +297,6 @@ export const useBases = defineStore('basesStore', () => { return { bases, basesList, - baseUserCount, loadProjects, loadProject, getSqlUi,