From b114d142d81eb93a6fcf27f6a0aeba4cb323c72d Mon Sep 17 00:00:00 2001 From: Kristina Date: Fri, 2 Feb 2024 19:35:40 +0400 Subject: [PATCH] UBERF-5020: fix reply to thread (#4502) Signed-off-by: Kristina Fefelova --- models/contact/src/index.ts | 1 - models/inventory/src/index.ts | 1 - models/lead/src/index.ts | 1 - models/recruit/src/index.ts | 1 - models/tracker/src/index.ts | 1 - plugins/chunter-resources/src/index.ts | 32 +++++++++++++++++++++----- 6 files changed, 26 insertions(+), 11 deletions(-) diff --git a/models/contact/src/index.ts b/models/contact/src/index.ts index 6800ba6aa2..d677b6c6f1 100644 --- a/models/contact/src/index.ts +++ b/models/contact/src/index.ts @@ -286,7 +286,6 @@ export function createModel (builder: Builder): void { hidden: false, // component: contact.component.ContactsTabs, locationResolver: contact.resolver.Location, - aside: chunter.component.ThreadView, navigatorModel: { spaces: [], specials: [ diff --git a/models/inventory/src/index.ts b/models/inventory/src/index.ts index ec63238fef..efd0f1e7cb 100644 --- a/models/inventory/src/index.ts +++ b/models/inventory/src/index.ts @@ -148,7 +148,6 @@ export function createModel (builder: Builder): void { icon: inventory.icon.InventoryApplication, alias: inventoryId, hidden: false, - aside: chunter.component.ThreadView, navigatorModel: { specials: [ { diff --git a/models/lead/src/index.ts b/models/lead/src/index.ts index 62432d50a7..49537dd150 100644 --- a/models/lead/src/index.ts +++ b/models/lead/src/index.ts @@ -155,7 +155,6 @@ export function createModel (builder: Builder): void { icon: lead.icon.LeadApplication, alias: leadId, hidden: false, - aside: chunter.component.ThreadView, navigatorModel: { specials: [ { diff --git a/models/recruit/src/index.ts b/models/recruit/src/index.ts index 7cf635ab1c..eb9dc6f9e2 100644 --- a/models/recruit/src/index.ts +++ b/models/recruit/src/index.ts @@ -302,7 +302,6 @@ export function createModel (builder: Builder): void { locationResolver: recruit.resolver.Location, alias: recruitId, hidden: false, - aside: chunter.component.ThreadView, navigatorModel: { spaces: [], specials: [ diff --git a/models/tracker/src/index.ts b/models/tracker/src/index.ts index 1e3a1fb6cc..53f93777b2 100644 --- a/models/tracker/src/index.ts +++ b/models/tracker/src/index.ts @@ -274,7 +274,6 @@ function defineApplication ( alias: trackerId, hidden: false, locationResolver: tracker.resolver.Location, - aside: chunter.component.ThreadView, navigatorModel: { specials: [ { diff --git a/plugins/chunter-resources/src/index.ts b/plugins/chunter-resources/src/index.ts index bf42879ebc..171e9aba13 100644 --- a/plugins/chunter-resources/src/index.ts +++ b/plugins/chunter-resources/src/index.ts @@ -21,12 +21,19 @@ import chunter, { chunterId, type DirectMessage } from '@hcengineering/chunter' -import { type Data, type Doc, type DocumentQuery, type Ref, type RelatedDocument } from '@hcengineering/core' +import { + type Data, + type Doc, + type DocumentQuery, + getCurrentAccount, + type Ref, + type RelatedDocument +} from '@hcengineering/core' import { type IntlString, type Resources, translate } from '@hcengineering/platform' import { MessageBox, getClient } from '@hcengineering/presentation' import { closePanel, getCurrentLocation, getLocation, navigate, showPopup } from '@hcengineering/ui' import activity, { type ActivityMessage, type DocUpdateMessage } from '@hcengineering/activity' -import { type DocNotifyContext, inboxId } from '@hcengineering/notification' +import notification, { type DocNotifyContext, inboxId } from '@hcengineering/notification' import ChannelPresenter from './components/ChannelPresenter.svelte' import ChannelView from './components/ChannelView.svelte' @@ -201,10 +208,23 @@ export async function deleteChatMessage (message: ChatMessage): Promise { export async function replyToThread (message: ActivityMessage): Promise { const loc = getCurrentLocation() - const inboxClient = InboxNotificationsClientImpl.getClient() - const context = get(inboxClient.docNotifyContextByDoc).get(message.attachedTo) + const client = getClient() - if (context === undefined) { + const inboxClient = InboxNotificationsClientImpl.getClient() + + let contextId: Ref | undefined = get(inboxClient.docNotifyContextByDoc).get(message.attachedTo)?._id + + if (contextId === undefined) { + contextId = await client.createDoc(notification.class.DocNotifyContext, message.space, { + attachedTo: message.attachedTo, + attachedToClass: message.attachedToClass, + user: getCurrentAccount()._id, + hidden: false, + lastViewedTimestamp: Date.now() + }) + } + + if (contextId === undefined) { return } @@ -212,7 +232,7 @@ export async function replyToThread (message: ActivityMessage): Promise { loc.path[2] = chunterId } - navigateToThread(loc, context._id, message._id) + navigateToThread(loc, contextId, message._id) } export default async (): Promise => ({