From e56282fec22a7b3fd90ce86ad36aced80fe123a0 Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 19 Sep 2022 12:26:58 +0200 Subject: [PATCH] refactor(nc-gui): replace computed with useState to prevent unnecessary duplicates --- packages/nc-gui/composables/useUIPermission/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/composables/useUIPermission/index.ts b/packages/nc-gui/composables/useUIPermission/index.ts index 7140957480..09b08cafcb 100644 --- a/packages/nc-gui/composables/useUIPermission/index.ts +++ b/packages/nc-gui/composables/useUIPermission/index.ts @@ -1,7 +1,7 @@ import { isString } from '@vueuse/core' import type { Permission } from './rolePermissions' import rolePermissions from './rolePermissions' -import { USER_PROJECT_ROLES, computed, useGlobal, useState } from '#imports' +import { USER_PROJECT_ROLES, useGlobal, useState } from '#imports' import type { ProjectRole, Role, Roles } from '~/lib' export function useUIPermission() { @@ -9,7 +9,7 @@ export function useUIPermission() { const projectRoles = useState>(USER_PROJECT_ROLES, () => ({})) - const baseRoles = computed(() => { + const allRoles = useState('allRoles', () => { let userRoles = user.value?.roles // if string populate key-value paired object @@ -28,7 +28,7 @@ export function useUIPermission() { }) const isUIAllowed = (permission: Permission | string, skipPreviewAs = false) => { - let roles = baseRoles.value + let roles = { ...allRoles.value } if (previewAs.value && !skipPreviewAs) { roles = {