From 667d22cb7a4a9905bb96523eb55748c74af7ba4c Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Mon, 28 Mar 2022 14:03:50 +0600 Subject: [PATCH] 1091 fix (#1206) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- .../src/components/Profile.svelte | 30 +++++-------------- .../src/components/Chat.svelte | 2 +- .../src/components/AccountPopup.svelte | 10 ++----- .../src/components/Workbench.svelte | 26 +++++----------- 4 files changed, 17 insertions(+), 51 deletions(-) diff --git a/plugins/setting-resources/src/components/Profile.svelte b/plugins/setting-resources/src/components/Profile.svelte index e2ad97d6ef..c41acb5f69 100644 --- a/plugins/setting-resources/src/components/Profile.svelte +++ b/plugins/setting-resources/src/components/Profile.svelte @@ -31,40 +31,24 @@ import { ChannelsEditor } from '@anticrm/contact-resources' const client = getClient() - let account: EmployeeAccount | undefined let employee: Employee | undefined let firstName: string let lastName: string - const accountQ = createQuery() const employeeQ = createQuery() - $: accountQ.query( - contact.class.EmployeeAccount, + + employeeQ.query( + contact.class.Employee, { - _id: getCurrentAccount()._id as Ref + _id: (getCurrentAccount() as EmployeeAccount).employee }, (res) => { - account = res[0] + employee = res[0] + firstName = getFirstName(employee.name) + lastName = getLastName(employee.name) }, { limit: 1 } ) - $: account && updateQuery(account.employee) - - function updateQuery (id: Ref): void { - employeeQ.query( - contact.class.Employee, - { - _id: id - }, - (res) => { - employee = res[0] - firstName = getFirstName(employee.name) - lastName = getLastName(employee.name) - }, - { limit: 1 } - ) - } - async function onAvatarDone (e: any) { if (employee === undefined) return const uploadFile = await getResource(attachment.helper.UploadFile) diff --git a/plugins/telegram-resources/src/components/Chat.svelte b/plugins/telegram-resources/src/components/Chat.svelte index 934529b954..11bd703e74 100644 --- a/plugins/telegram-resources/src/components/Chat.svelte +++ b/plugins/telegram-resources/src/components/Chat.svelte @@ -27,7 +27,7 @@ import Connect from './Connect.svelte' import TelegramIcon from './icons/Telegram.svelte' import Messages from './Messages.svelte' -import Reconnect from './Reconnect.svelte'; + import Reconnect from './Reconnect.svelte' export let object: Contact let channel: Channel | undefined = undefined diff --git a/plugins/workbench-resources/src/components/AccountPopup.svelte b/plugins/workbench-resources/src/components/AccountPopup.svelte index b8d32ff3b9..f5e83d69d0 100644 --- a/plugins/workbench-resources/src/components/AccountPopup.svelte +++ b/plugins/workbench-resources/src/components/AccountPopup.svelte @@ -26,17 +26,11 @@ return await client.findAll(setting.class.SettingsCategory, {}, { sort: { order: 1 } }) } - let account: EmployeeAccount | undefined + const account = getCurrentAccount() as EmployeeAccount let employee: Employee | undefined - const accountQ = createQuery() const employeeQ = createQuery() - $: accountQ.query(contact.class.EmployeeAccount, { - _id: getCurrentAccount()._id as Ref - }, (res) => { - account = res[0] - }, { limit: 1 }) - $: account && employeeQ.query(contact.class.Employee, { + employeeQ.query(contact.class.Employee, { _id: account.employee }, (res) => { employee = res[0] diff --git a/plugins/workbench-resources/src/components/Workbench.svelte b/plugins/workbench-resources/src/components/Workbench.svelte index fd19a11173..770374533a 100644 --- a/plugins/workbench-resources/src/components/Workbench.svelte +++ b/plugins/workbench-resources/src/components/Workbench.svelte @@ -151,33 +151,21 @@ visibileNav = !visibileNav closeTooltip() } - let account: EmployeeAccount | undefined + const account = getCurrentAccount() as EmployeeAccount let employee: Employee | undefined - const accountQ = createQuery() const employeeQ = createQuery() - $: accountQ.query( - contact.class.EmployeeAccount, + + employeeQ.query( + contact.class.Employee, { - _id: getCurrentAccount()._id as Ref + _id: account.employee }, (res) => { - account = res[0] + employee = res[0] }, { limit: 1 } ) - $: account && - employeeQ.query( - contact.class.Employee, - { - _id: account.employee - }, - (res) => { - employee = res[0] - }, - { limit: 1 } - ) - let isNavigate: boolean = false $: isNavigate = !!navigatorModel @@ -210,7 +198,7 @@ $: notificationQuery.query( notification.class.Notification, { - attachedTo: (getCurrentAccount() as EmployeeAccount).employee, + attachedTo: account.employee, status: NotificationStatus.New }, (res) => {