Skip to content

Commit

Permalink
UBERF-4161: Few inbox fixes (#3976)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
  • Loading branch information
haiodo authored Nov 13, 2023
1 parent 0a16c2f commit 29b9296
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 26 deletions.
2 changes: 1 addition & 1 deletion plugins/chunter-resources/src/components/DmHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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<PersonAccount>[] }
_id: { $in: (empAccIds ?? []) as Ref<PersonAccount>[] }
})
return employeeAccounts.map((ea) => ea.person)
Expand Down
3 changes: 2 additions & 1 deletion plugins/client-resources/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 18 additions & 4 deletions plugins/contact-resources/src/components/AccountArrayEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -30,17 +31,30 @@
export let width: string | undefined = undefined
export let excludeItems: Ref<Account>[] | undefined = undefined
let timer: any
let timer: any = null
const client = getClient()
let update: (() => Promise<void>) | undefined
function onUpdate (evt: CustomEvent<Ref<Employee>[]>): 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[] = []
Expand Down
32 changes: 17 additions & 15 deletions plugins/contact-resources/src/components/CombineAvatars.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,19 @@
import EmptyAvatar from './icons/EmptyAvatar.svelte'
export let _class: Ref<Class<Contact>>
export let items: (Ref<Contact> | undefined | null)[] = []
export let items: (Ref<Contact> | 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<Contact>(
_class,
{ _id: { $in: items.filter((p) => p) as Ref<Contact>[] } },
{ _id: { $in: (items?.filter((p) => p) as Ref<Contact>[]) ?? [] } },
(result) => {
persons = result
},
Expand All @@ -48,18 +48,20 @@
}
</script>

<div class="avatars-container">
{#if includeEmpty}
<div class="combine-avatar {size}" data-over={getDataOver(persons.length === 0, items)}>
<EmptyAvatar {size} />
</div>
{/if}
{#each persons as person, i}
<div class="combine-avatar {size}" data-over={getDataOver(persons.length === i + 1, items)}>
<Avatar avatar={person.avatar} {size} name={person.name} />
</div>
{/each}
</div>
{#if items !== undefined}
<div class="avatars-container">
{#if includeEmpty}
<div class="combine-avatar {size}" data-over={getDataOver(persons.length === 0, items)}>
<EmptyAvatar {size} />
</div>
{/if}
{#each persons as person, i}
<div class="combine-avatar {size}" data-over={getDataOver(persons.length === i + 1, items)}>
<Avatar avatar={person.avatar} {size} name={person.name} />
</div>
{/each}
</div>
{/if}

<style lang="scss">
.avatars-container {
Expand Down
4 changes: 2 additions & 2 deletions plugins/contact-resources/src/components/ContactList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import IconMembers from './icons/Members.svelte'
import UsersPopup from './UsersPopup.svelte'
export let items: Ref<Contact>[] = []
export let items: Ref<Contact>[] | undefined = []
export let _class: Ref<Class<Contact>> = contact.class.Contact
export let label: IntlString
export let docQuery: DocumentQuery<Contact> | undefined = {}
Expand All @@ -42,7 +42,7 @@
const query = createQuery()
$: query.query<Contact>(_class, { _id: { $in: items } }, (result) => {
$: query.query<Contact>(_class, { _id: { $in: items ?? [] } }, (result) => {
contacts = result
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
createFocusManager,
getCurrentResolvedLocation,
navigate,
showPopup,
deviceOptionsStore as deviceInfo
showPopup
} from '@hcengineering/ui'
import { ContextMenu, DocNavLink, ParentsNavigator } from '@hcengineering/view-resources'
import view from '@hcengineering/view'
Expand Down Expand Up @@ -251,7 +250,6 @@
placeholder={tracker.string.IssueTitlePlaceholder}
kind="large-style"
on:blur={save}
autoFocus={!$deviceInfo.isMobile}
/>
<div class="w-full mt-6">
<AttachmentStyleBoxEditor
Expand Down

0 comments on commit 29b9296

Please sign in to comment.