From f0bbd4d443428e79b4d6baafc054943c36ac1664 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Fri, 17 Mar 2023 22:05:22 +0600 Subject: [PATCH] TSK-852 List perform individual requests (#2765) Signed-off-by: Denis Bykhov --- .../src/components/AddMembersPopup.svelte | 8 +- .../src/components/CommentPresenter.svelte | 3 +- .../src/components/Message.svelte | 18 +- .../src/components/PinnedMessagesPopup.svelte | 8 +- .../src/components/ReactionsTooltip.svelte | 7 +- .../src/components/Replies.svelte | 31 +-- .../src/components/SavedMessages.svelte | 8 +- .../src/components/Thread.svelte | 9 +- plugins/chunter-resources/src/utils.ts | 14 +- .../EmployeeAccountPresenter.svelte | 13 +- .../components/EmployeePreviewPopup.svelte | 15 +- .../components/EmployeeRefPresenter.svelte | 7 +- plugins/contact-resources/src/index.ts | 1 + plugins/contact-resources/src/utils.ts | 53 ++-- plugins/contact/src/index.ts | 260 +----------------- plugins/contact/src/types.ts | 45 +++ plugins/contact/src/utils.ts | 228 +++++++++++++++ .../src/components/Chats.svelte | 13 +- .../src/components/RequestView.svelte | 17 +- .../src/components/Owners.svelte | 14 +- .../src/components/Profile.svelte | 34 +-- plugins/setting-resources/src/utils.ts | 6 +- .../src/components/AccountPopup.svelte | 19 +- .../src/components/issues/KanbanView.svelte | 24 +- .../issues/edit/ControlPanel.svelte | 17 +- 25 files changed, 405 insertions(+), 467 deletions(-) create mode 100644 plugins/contact/src/types.ts create mode 100644 plugins/contact/src/utils.ts diff --git a/packages/presentation/src/components/AddMembersPopup.svelte b/packages/presentation/src/components/AddMembersPopup.svelte index 87e326ff27..da90635248 100644 --- a/packages/presentation/src/components/AddMembersPopup.svelte +++ b/packages/presentation/src/components/AddMembersPopup.svelte @@ -1,19 +1,17 @@ diff --git a/plugins/chunter-resources/src/components/SavedMessages.svelte b/plugins/chunter-resources/src/components/SavedMessages.svelte index 0791b8a96e..11280780fa 100644 --- a/plugins/chunter-resources/src/components/SavedMessages.svelte +++ b/plugins/chunter-resources/src/components/SavedMessages.svelte @@ -2,7 +2,8 @@ import attachment, { Attachment } from '@hcengineering/attachment' import AttachmentPreview from '@hcengineering/attachment-resources/src/components/AttachmentPreview.svelte' import { ChunterMessage } from '@hcengineering/chunter' - import contact, { Employee, EmployeeAccount, getName as getContactName } from '@hcengineering/contact' + import contact, { EmployeeAccount, getName as getContactName } from '@hcengineering/contact' + import { employeeByIdStore } from '@hcengineering/contact-resources' import core, { IdMap, Ref, toIdMap, WithLookup } from '@hcengineering/core' import { createQuery, getClient } from '@hcengineering/presentation' import { Label, Scroller } from '@hcengineering/ui' @@ -17,17 +18,14 @@ let savedAttachmentsIds: Ref[] = [] let savedAttachments: WithLookup[] = [] let accounts: IdMap = new Map() - let employees: IdMap = new Map() const messagesQuery = createQuery() const attachmentsQuery = createQuery() const savedMessagesQuery = createQuery() const savedAttachmentsQuery = createQuery() const accQ = createQuery() - const empQ = createQuery() accQ.query(contact.class.EmployeeAccount, {}, (res) => (accounts = toIdMap(res))) - empQ.query(contact.class.Employee, {}, (res) => (employees = toIdMap(res))) savedMessagesQuery.query(chunter.class.SavedMessages, {}, (res) => { savedMessagesIds = res.map((r) => r.attachedTo) @@ -83,7 +81,7 @@ function getName (a: Attachment): string | undefined { const acc = accounts.get(a.modifiedBy as Ref) if (acc !== undefined) { - const emp = employees.get(acc?.employee) + const emp = $employeeByIdStore.get(acc?.employee) if (emp !== undefined) { return getContactName(emp) } diff --git a/plugins/chunter-resources/src/components/Thread.svelte b/plugins/chunter-resources/src/components/Thread.svelte index de9c13b15c..57a52668b0 100644 --- a/plugins/chunter-resources/src/components/Thread.svelte +++ b/plugins/chunter-resources/src/components/Thread.svelte @@ -17,6 +17,7 @@ import { AttachmentRefInput } from '@hcengineering/attachment-resources' import type { ChunterSpace, Message, ThreadMessage } from '@hcengineering/chunter' import contact, { Employee, EmployeeAccount, getName } from '@hcengineering/contact' + import { employeeByIdStore } from '@hcengineering/contact-resources' import core, { FindOptions, generateId, @@ -24,7 +25,6 @@ IdMap, Ref, SortingOrder, - toIdMap, TxFactory } from '@hcengineering/core' import { NotificationClientImpl } from '@hcengineering/notification-resources' @@ -102,11 +102,6 @@ ) } - let employees: IdMap = new Map() - const employeeQuery = createQuery() - - employeeQuery.query(contact.class.Employee, {}, (res) => (employees = toIdMap(res))) - async function getParticipants ( comments: ThreadMessage[], parent: Message | undefined, @@ -176,7 +171,7 @@ {/if} {/await} - {#await getParticipants(comments, parent, employees) then participants} + {#await getParticipants(comments, parent, $employeeByIdStore) then participants} {participants.join(', ')}