Fix undefined error on thread open (#7169)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-11-13 18:42:38 +04:00 committed by GitHub
parent 99a35e08db
commit f7d8edccd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,7 +18,7 @@
import activity, { ActivityExtension } from '@hcengineering/activity'
import { getClient } from '@hcengineering/presentation'
import { AnySvelteComponent, Icon, Label } from '@hcengineering/ui'
import { Asset, getResource, translate } from '@hcengineering/platform'
import { Asset, getResource, IntlString } from '@hcengineering/platform'
import view from '@hcengineering/view'
import { getChannelName, getObjectIcon } from '../utils'
@ -38,10 +38,8 @@
$: extensions = client.getModel().findAllSync(activity.class.ActivityExtension, { ofClass: object._class })
let icon: Asset | AnySvelteComponent | undefined = undefined
let name: string | undefined = undefined
$: void updateIcon(object._class)
$: void updateName(object)
async function updateIcon (_class: Ref<Class<Doc>>): Promise<void> {
if (isThread) {
@ -58,9 +56,11 @@
icon = result
}
async function updateName (object: Doc): Promise<void> {
const titleIntl = client.getHierarchy().getClass(object._class).label
name = (await getChannelName(object._id, object._class, object)) ?? (await translate(titleIntl, {}))
async function getName (object: Doc): Promise<{ name: string | undefined, label: IntlString | undefined }> {
const name = await getChannelName(object._id, object._class, object)
const label = client.getHierarchy().getClass(object._class).label
return { name, label }
}
</script>
@ -82,9 +82,13 @@
{#if icon}
<Icon {icon} size="x-small" />
{/if}
{#if name}
{name}
{/if}
{#await getName(object) then data}
{#if data.name}
{data.name}
{:else if data.label}
<Label label={data.label} />
{/if}
{/await}
</span>
{/if}
</div>