Fix profile (#2816)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-03-23 11:31:38 +06:00 committed by GitHub
parent 3c8f29beb2
commit a48012037d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 9 deletions

View File

@ -1,13 +1,13 @@
import { chunterId, ChunterMessage, Comment, ThreadMessage } from '@hcengineering/chunter'
import contact, { EmployeeAccount, getName } from '@hcengineering/contact'
import contact, { Employee, EmployeeAccount, getName } from '@hcengineering/contact'
import { employeeByIdStore } from '@hcengineering/contact-resources'
import { Class, Client, Doc, getCurrentAccount, Obj, Ref, Space, Timestamp } from '@hcengineering/core'
import { Class, Client, Doc, getCurrentAccount, IdMap, Obj, Ref, Space, Timestamp } from '@hcengineering/core'
import { Asset } from '@hcengineering/platform'
import { getClient } from '@hcengineering/presentation'
import { getCurrentLocation, getPanelURI, location, Location, navigate, ResolvedLocation } from '@hcengineering/ui'
import view from '@hcengineering/view'
import { workbenchId } from '@hcengineering/workbench'
import { get, writable } from 'svelte/store'
import { get, Unsubscriber, writable } from 'svelte/store'
import chunter from './plugin'
@ -49,7 +49,19 @@ export async function getDmName (client: Client, dm: Space): Promise<string> {
employeeAccounts = employeeAccounts.filter((p) => p._id !== myAccId)
}
const map = get(employeeByIdStore)
let unsub: Unsubscriber | undefined
const promise = new Promise<IdMap<Employee>>((resolve) => {
unsub = employeeByIdStore.subscribe((p) => {
if (p.size !== 0) {
resolve(p)
}
})
})
const map = await promise
unsub?.()
const names: string[] = []
for (const acc of employeeAccounts) {

View File

@ -14,24 +14,35 @@
-->
<script lang="ts">
import contact, { EmployeeAccount, getFirstName, getLastName } from '@hcengineering/contact'
import { ChannelsEditor, employeeByIdStore } from '@hcengineering/contact-resources'
import { ChannelsEditor, EditableAvatar, employeeByIdStore } from '@hcengineering/contact-resources'
import { getCurrentAccount } from '@hcengineering/core'
import login from '@hcengineering/login'
import { getResource } from '@hcengineering/platform'
import { AttributeEditor, getClient, MessageBox } from '@hcengineering/presentation'
import { EditableAvatar } from '@hcengineering/contact-resources'
import { Button, createFocusManager, EditBox, FocusHandler, Icon, Label, showPopup } from '@hcengineering/ui'
import { onDestroy } from 'svelte'
import setting from '../plugin'
const client = getClient()
let avatarEditor: EditableAvatar
const account = getCurrentAccount() as EmployeeAccount
$: employee = $employeeByIdStore.get(account.employee)
let firstName: string = employee ? getFirstName(employee.name) : ''
let lastName: string = employee ? getLastName(employee.name) : ''
const employee = $employeeByIdStore.get(account.employee)
let firstName = employee ? getFirstName(employee.name) : ''
let lastName = employee ? getLastName(employee.name) : ''
let displayName = employee?.displayName ?? ''
onDestroy(
employeeByIdStore.subscribe((p) => {
const emp = p.get(account.employee)
if (emp) {
firstName = getFirstName(emp.name)
lastName = getLastName(emp.name)
displayName = emp?.displayName ?? ''
}
})
)
async function onAvatarDone (e: any) {
if (employee === undefined) return