Skip to content

Commit

Permalink
Fix undefined error on thread open (#7169)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristina Fefelova <[email protected]>
  • Loading branch information
kristina-fefelova authored Nov 13, 2024
1 parent 99a35e0 commit f7d8edc
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions plugins/chunter-resources/src/components/ChannelInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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) {
Expand All @@ -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>

Expand All @@ -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>
Expand Down

0 comments on commit f7d8edc

Please sign in to comment.