diff --git a/plugins/chunter-resources/src/components/DmHeader.svelte b/plugins/chunter-resources/src/components/DmHeader.svelte index edcda3777a..43f35bf746 100644 --- a/plugins/chunter-resources/src/components/DmHeader.svelte +++ b/plugins/chunter-resources/src/components/DmHeader.svelte @@ -44,7 +44,7 @@ const empAccIds = dm?.members.length !== 1 ? dm?.members.filter((accId) => accId !== myAccId) : dm?.members const employeeAccounts = await client.findAll(contact.class.PersonAccount, { - _id: { $in: empAccIds as Ref[] } + _id: { $in: (empAccIds ?? []) as Ref[] } }) return employeeAccounts.map((ea) => ea.person) diff --git a/plugins/client-resources/src/connection.ts b/plugins/client-resources/src/connection.ts index cf9189be6c..c8cff4034a 100644 --- a/plugins/client-resources/src/connection.ts +++ b/plugins/client-resources/src/connection.ts @@ -236,9 +236,10 @@ class Connection implements ClientConnection { } } + const request = this.requests.get(resp.id) this.requests.delete(resp.id) if (resp.error !== undefined) { - console.log('ERROR', promise, resp.id) + console.log('ERROR', promise, request, resp.id) promise.reject(new PlatformError(resp.error)) } else { promise.resolve(resp.result) diff --git a/plugins/contact-resources/src/components/AccountArrayEditor.svelte b/plugins/contact-resources/src/components/AccountArrayEditor.svelte index 8de6c8c7e4..9e8e8d2745 100644 --- a/plugins/contact-resources/src/components/AccountArrayEditor.svelte +++ b/plugins/contact-resources/src/components/AccountArrayEditor.svelte @@ -18,6 +18,7 @@ import { IntlString } from '@hcengineering/platform' import { createQuery, getClient } from '@hcengineering/presentation' import { ButtonKind, ButtonSize } from '@hcengineering/ui' + import { onDestroy } from 'svelte' import { personAccountByIdStore } from '../utils' import UserBoxList from './UserBoxList.svelte' @@ -30,17 +31,30 @@ export let width: string | undefined = undefined export let excludeItems: Ref[] | undefined = undefined - let timer: any + let timer: any = null const client = getClient() + let update: (() => Promise) | undefined function onUpdate (evt: CustomEvent[]>): void { - clearTimeout(timer) - timer = setTimeout(async () => { + if (timer !== null) { + clearTimeout(timer) + } + update = async () => { const accounts = await client.findAll(contact.class.PersonAccount, { person: { $in: evt.detail } }) onChange(accounts.map((it) => it._id)) - }, 500) + if (timer !== null) { + clearTimeout(timer) + } + timer = null + update = undefined + } + timer = setTimeout(() => update?.(), 500) } + onDestroy(() => { + update?.() + }) + const excludedQuery = createQuery() let excluded: Account[] = [] diff --git a/plugins/contact-resources/src/components/CombineAvatars.svelte b/plugins/contact-resources/src/components/CombineAvatars.svelte index 4706e0c4c9..eedd58652c 100644 --- a/plugins/contact-resources/src/components/CombineAvatars.svelte +++ b/plugins/contact-resources/src/components/CombineAvatars.svelte @@ -21,19 +21,19 @@ import EmptyAvatar from './icons/EmptyAvatar.svelte' export let _class: Ref> - export let items: (Ref | undefined | null)[] = [] + export let items: (Ref | undefined | null)[] | undefined = [] export let size: IconSize export let limit: number = 3 export let hideLimit: boolean = false let persons: Contact[] = [] - $: includeEmpty = items.includes(undefined) || items.includes(null) + $: includeEmpty = items?.includes(undefined) || items?.includes(null) const query = createQuery() $: query.query( _class, - { _id: { $in: items.filter((p) => p) as Ref[] } }, + { _id: { $in: (items?.filter((p) => p) as Ref[]) ?? [] } }, (result) => { persons = result }, @@ -48,18 +48,20 @@ } -
- {#if includeEmpty} -
- -
- {/if} - {#each persons as person, i} -
- -
- {/each} -
+{#if items !== undefined} +
+ {#if includeEmpty} +
+ +
+ {/if} + {#each persons as person, i} +
+ +
+ {/each} +
+{/if}