|
|
@ -92,25 +92,32 @@ export const useBases = defineStore('basesStore', () => { |
|
|
|
const loadProjects = async (page: 'recent' | 'shared' | 'starred' | 'workspace' = 'recent') => { |
|
|
|
const loadProjects = async (page: 'recent' | 'shared' | 'starred' | 'workspace' = 'recent') => { |
|
|
|
// if shared base then get the shared base and create a list
|
|
|
|
// if shared base then get the shared base and create a list
|
|
|
|
if (route.value.params.typeOrId === 'base' && route.value.params.baseId) { |
|
|
|
if (route.value.params.typeOrId === 'base' && route.value.params.baseId) { |
|
|
|
const { base_id } = await $api.public.sharedBaseGet(route.value.params.baseId as string) |
|
|
|
try { |
|
|
|
const base: BaseType = await $api.base.read(base_id) |
|
|
|
const { base_id } = await $api.public.sharedBaseGet(route.value.params.baseId as string) |
|
|
|
|
|
|
|
const base: BaseType = await $api.base.read(base_id) |
|
|
|
|
|
|
|
|
|
|
|
if (!base) return |
|
|
|
if (!base) return |
|
|
|
|
|
|
|
|
|
|
|
bases.value = [base].reduce((acc, base) => { |
|
|
|
bases.value = [base].reduce((acc, base) => { |
|
|
|
acc.set(base.id!, base) |
|
|
|
acc.set(base.id!, base) |
|
|
|
return acc |
|
|
|
return acc |
|
|
|
}, new Map()) |
|
|
|
}, new Map()) |
|
|
|
|
|
|
|
|
|
|
|
bases.value.set(base.id!, { |
|
|
|
bases.value.set(base.id!, { |
|
|
|
...(bases.value.get(base.id!) || {}), |
|
|
|
...(bases.value.get(base.id!) || {}), |
|
|
|
...base, |
|
|
|
...base, |
|
|
|
sources: [...(base.sources ?? bases.value.get(base.id!)?.sources ?? [])], |
|
|
|
sources: [...(base.sources ?? bases.value.get(base.id!)?.sources ?? [])], |
|
|
|
isExpanded: route.value.params.baseId === base.id || bases.value.get(base.id!)?.isExpanded, |
|
|
|
isExpanded: route.value.params.baseId === base.id || bases.value.get(base.id!)?.isExpanded, |
|
|
|
isLoading: false, |
|
|
|
isLoading: false, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
} catch (e: any) { |
|
|
|
|
|
|
|
if (e?.response?.status === 404) { |
|
|
|
|
|
|
|
return router.push('/error/404') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
throw e |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const activeWorkspace = workspaceStore.activeWorkspace |
|
|
|
const activeWorkspace = workspaceStore.activeWorkspace |
|
|
|