diff --git a/packages/presentation/src/components/Channels.svelte b/packages/presentation/src/components/Channels.svelte index 13b5bb530d..a6753c533c 100644 --- a/packages/presentation/src/components/Channels.svelte +++ b/packages/presentation/src/components/Channels.svelte @@ -26,7 +26,7 @@ import contact from '@anticrm/contact' import { createEventDispatcher } from 'svelte' - export let value: AttachedData[] | null + export let value: AttachedData[] | AttachedData | null export let size: 'small' | 'medium' | 'large' | 'x-large' = 'large' export let reverse: boolean = false export let integrations: Set> = new Set>() @@ -51,21 +51,35 @@ return map } - async function update (value: AttachedData[]) { + function getProvider (item: AttachedData, map: Map, ChannelProvider>): any | undefined { + const provider = map.get(item.provider) + if (provider) { + return { + label: provider.label as IntlString, + icon: provider.icon as Asset, + value: item.value, + presenter: provider.presenter, + integration: provider.integrationType !== undefined ? integrations.has(provider.integrationType) : false + } + } else { + console.log('provider not found: ', item.provider) + } + } + + async function update (value: AttachedData[] | AttachedData) { const result = [] const map = await getProviders() - for (const item of value) { - const provider = map.get(item.provider) - if (provider) { - result.push({ - label: provider.label as IntlString, - icon: provider.icon as Asset, - value: item.value, - presenter: provider.presenter, - integration: provider.integrationType !== undefined ? integrations.has(provider.integrationType) : false - }) - } else { - console.log('provider not found: ', item.provider) + if (Array.isArray(value)) { + for (const item of value) { + const provider = getProvider(item, map) + if (provider !== undefined) { + result.push(provider) + } + } + } else { + const provider = getProvider(value, map) + if (provider !== undefined) { + result.push(provider) } } displayItems = result diff --git a/plugins/contact-resources/src/components/ChannelsPresenter.svelte b/plugins/contact-resources/src/components/ChannelsPresenter.svelte index 508a4b3b21..28ba5d0df0 100644 --- a/plugins/contact-resources/src/components/ChannelsPresenter.svelte +++ b/plugins/contact-resources/src/components/ChannelsPresenter.svelte @@ -17,7 +17,7 @@ import type { Channel } from '@anticrm/contact' import { Channels } from '@anticrm/presentation' - export let value: Channel[] | null + export let value: Channel[] | Channel | null