mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-12 12:47:45 +02:00
Make visibleIf async in SpecialNavModel (#2684)
Signed-off-by: Denis Bunakalya <denis.bunakalya@xored.com>
This commit is contained in:
@@ -107,20 +107,27 @@
|
||||
requestIndex: number
|
||||
): Promise<[Map<string, SpecialNavModel[]>, number]> {
|
||||
const result = new Map<string, SpecialNavModel[]>()
|
||||
const promises = specials.map(async (sp) => {
|
||||
const pos = sp.position ?? 'top'
|
||||
let visible = true
|
||||
if (sp.visibleIf !== undefined) {
|
||||
const f = await getResource(sp.visibleIf)
|
||||
visible = f(spaces)
|
||||
}
|
||||
if (visible) {
|
||||
const list = result.get(pos) ?? []
|
||||
list.push(sp)
|
||||
result.set(pos, list)
|
||||
}
|
||||
})
|
||||
await Promise.all(promises)
|
||||
|
||||
const spHandlers = await Promise.all(
|
||||
specials.map(async (sp) => {
|
||||
const pos = sp.position ?? 'top'
|
||||
let visible = true
|
||||
if (sp.visibleIf !== undefined) {
|
||||
const f = await getResource(sp.visibleIf)
|
||||
visible = await f(spaces)
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (visible) {
|
||||
const list = result.get(pos) ?? []
|
||||
list.push(sp)
|
||||
result.set(pos, list)
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
spHandlers.forEach((spHandler) => spHandler())
|
||||
|
||||
return [result, requestIndex]
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -23,7 +23,7 @@ import SpecialView from './components/SpecialView.svelte'
|
||||
import WorkbenchApp from './components/WorkbenchApp.svelte'
|
||||
import { doNavigate } from './utils'
|
||||
|
||||
function hasArchiveSpaces (spaces: Space[]): boolean {
|
||||
async function hasArchiveSpaces (spaces: Space[]): Promise<boolean> {
|
||||
return spaces.find((sp) => sp.archived) !== undefined
|
||||
}
|
||||
export { default as SpaceBrowser } from './components/SpaceBrowser.svelte'
|
||||
|
||||
Reference in New Issue
Block a user