Add chat fixes (#6682)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina
2024-09-23 13:36:08 +07:00
committed by GitHub
parent 4bdfaaa28e
commit bbe2e4e9ce
10 changed files with 62 additions and 29 deletions
@@ -21,7 +21,8 @@
location as locationStore,
Location,
Header,
Breadcrumbs
Breadcrumbs,
getCurrentLocation
} from '@hcengineering/ui'
import { onDestroy } from 'svelte'
@@ -45,13 +46,33 @@
$: widgetState = widget !== undefined ? $sidebarStore.widgetsState.get(widget._id) : undefined
$: tabId = widgetState?.tab
$: tabs = widgetState?.tabs ?? []
$: tabs = getTabs(widget, widgetState)
$: tab = tabId !== undefined ? tabs.find((it) => it.id === tabId) ?? tabs[0] : tabs[0]
$: if ($sidebarStore.widget === undefined) {
sidebarStore.update((s) => ({ ...s, variant: SidebarVariant.MINI }))
}
function getTabs (widget?: Widget, state?: WidgetState): WidgetTab[] {
if (widget === undefined || !state?.tabs) return []
const loc = getCurrentLocation()
const result: WidgetTab[] = []
for (const tab of state.tabs) {
if (tab.allowedPath !== undefined && !tab.isPinned) {
const path = loc.path.join('/')
if (!path.startsWith(tab.allowedPath)) {
void handleTabClose(tab.id, widget)
continue
}
}
result.push(tab)
}
return result
}
const unsubscribe = locationStore.subscribe((loc: Location) => {
if (widget === undefined) return