Browse Source

fix(nc-gui): cleanup sidebar state on scope dispose

pull/3671/head
braks 2 years ago
parent
commit
0a1e224273
  1. 6
      packages/nc-gui/composables/useSidebar/index.ts
  2. 3
      packages/nc-gui/composables/useUIPermission/index.ts

6
packages/nc-gui/composables/useSidebar/index.ts

@ -1,5 +1,5 @@
import { useStorage } from '@vueuse/core'
import { MemStorage, useInjectionState, watch } from '#imports'
import { MemStorage, onScopeDispose, useInjectionState, watch } from '#imports'
interface UseSidebarProps {
hasSidebar?: boolean
@ -72,6 +72,10 @@ const useSidebarStorage = () => {
export const provideSidebar = (id: string, props: UseSidebarProps = {}) => {
const sidebarStorage = useSidebarStorage()
onScopeDispose(() => {
sidebarStorage.remove(id)
})
if (!sidebarStorage.has(id)) {
const sidebar = createSidebar(id, props)

3
packages/nc-gui/composables/useUIPermission/index.ts

@ -1,3 +1,4 @@
import { isString } from '@vueuse/core'
import type { Permission } from './rolePermissions'
import rolePermissions from './rolePermissions'
import { USER_PROJECT_ROLES, computed, useGlobal, useState } from '#imports'
@ -9,7 +10,7 @@ export function useUIPermission() {
const projectRoles = useState<Record<string, boolean>>(USER_PROJECT_ROLES, () => ({}))
const baseRoles = computed(() => {
let userRoles = typeof user.value?.roles === 'string' ? user.value?.roles : ({ ...(user.value?.roles || {}) } as Roles)
let userRoles = isString(user.value?.roles) ? user.value?.roles : ({ ...(user.value?.roles || {}) } as Roles)
// if string populate key-value paired object
if (typeof userRoles === 'string') {

Loading…
Cancel
Save