Add chat and inbox fixes (#6779)

Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
Kristina 2024-10-02 11:00:17 +04:00 committed by GitHub
parent 47d14885e5
commit 99749f30fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 45 additions and 14 deletions

View File

@ -40,6 +40,6 @@
kind="tertiary" kind="tertiary"
pressed={opened} pressed={opened}
{dataId} {dataId}
tooltip={{ label }} tooltip={{ label, direction: 'bottom' }}
on:click={onClick} on:click={onClick}
/> />

View File

@ -81,7 +81,7 @@
"Reacted": "Отреагировал(а)", "Reacted": "Отреагировал(а)",
"Docs": "Documents", "Docs": "Documents",
"NewestFirst": "Сначала новые", "NewestFirst": "Сначала новые",
"ReplyToThread": "Ответить в канале", "ReplyToThread": "Ответить в теме",
"SentMessage": "Отправил(а) сообщение", "SentMessage": "Отправил(а) сообщение",
"Direct": "Личные сообщения", "Direct": "Личные сообщения",
"RepliedToThread": "Ответил(а) в канале", "RepliedToThread": "Ответил(а) в канале",

View File

@ -379,7 +379,7 @@
function messageInView (msgElement: Element, containerRect: DOMRect): boolean { function messageInView (msgElement: Element, containerRect: DOMRect): boolean {
const messageRect = msgElement.getBoundingClientRect() const messageRect = msgElement.getBoundingClientRect()
return messageRect.top >= containerRect.top && messageRect.bottom - messageRect.height / 2 <= containerRect.bottom return messageRect.top >= containerRect.top && messageRect.top <= containerRect.bottom && messageRect.bottom >= 0
} }
const messagesToReadAccumulator: Set<DisplayActivityMessage> = new Set<DisplayActivityMessage>() const messagesToReadAccumulator: Set<DisplayActivityMessage> = new Set<DisplayActivityMessage>()

View File

@ -151,7 +151,7 @@ export async function buildThreadLink (
loc.path[2] = chunterId loc.path[2] = chunterId
} }
loc.query = { message: '' } loc.query = { ...loc.query, message: '' }
loc.path[3] = objectURI loc.path[3] = objectURI
loc.path[4] = threadParent loc.path[4] = threadParent
loc.fragment = undefined loc.fragment = undefined

View File

@ -15,7 +15,7 @@
<script lang="ts"> <script lang="ts">
import activity, { ActivityMessage } from '@hcengineering/activity' import activity, { ActivityMessage } from '@hcengineering/activity'
import chunter from '@hcengineering/chunter' import chunter from '@hcengineering/chunter'
import { getCurrentAccount, groupByArray, IdMap, Ref, SortingOrder } from '@hcengineering/core' import { Class, Doc, getCurrentAccount, groupByArray, IdMap, Ref, SortingOrder } from '@hcengineering/core'
import { DocNotifyContext, InboxNotification, notificationId } from '@hcengineering/notification' import { DocNotifyContext, InboxNotification, notificationId } from '@hcengineering/notification'
import { ActionContext, createQuery, getClient } from '@hcengineering/presentation' import { ActionContext, createQuery, getClient } from '@hcengineering/presentation'
import { import {
@ -68,6 +68,9 @@
const linkProviders = client.getModel().findAllSync(view.mixin.LinkIdProvider, {}) const linkProviders = client.getModel().findAllSync(view.mixin.LinkIdProvider, {})
let urlObjectId: Ref<Doc> | undefined = undefined
let urlObjectClass: Ref<Class<Doc>> | undefined = undefined
let showArchive = false let showArchive = false
let archivedActivityNotifications: InboxNotification[] = [] let archivedActivityNotifications: InboxNotification[] = []
let archivedOtherNotifications: InboxNotification[] = [] let archivedOtherNotifications: InboxNotification[] = []
@ -165,14 +168,19 @@
if (loc?.loc.path[3] == null) { if (loc?.loc.path[3] == null) {
selectedContext = undefined selectedContext = undefined
urlObjectId = undefined
urlObjectClass = undefined
restoreLocation(newLocation, notificationId) restoreLocation(newLocation, notificationId)
return return
} }
const [id, _class] = decodeObjectURI(loc?.loc.path[3] ?? '') const [id, _class] = decodeObjectURI(loc?.loc.path[3] ?? '')
const _id = await parseLinkId(linkProviders, id, _class) const _id = await parseLinkId(linkProviders, id, _class)
urlObjectId = _id
urlObjectClass = _class
const thread = loc?.loc.path[4] as Ref<ActivityMessage> const thread = loc?.loc.path[4] as Ref<ActivityMessage>
const context = $contextByDocStore.get(thread) ?? $contextByDocStore.get(_id) const queryContext = loc.loc.query?.context as Ref<DocNotifyContext>
const context = $contextByIdStore.get(queryContext) ?? $contextByDocStore.get(thread) ?? $contextByDocStore.get(_id)
selectedContextId = context?._id selectedContextId = context?._id
@ -199,7 +207,7 @@
$: selectedContext = selectedContextId ? selectedContext ?? $contextByIdStore.get(selectedContextId) : undefined $: selectedContext = selectedContextId ? selectedContext ?? $contextByIdStore.get(selectedContextId) : undefined
$: void updateSelectedPanel(selectedContext) $: void updateSelectedPanel(selectedContext, urlObjectClass)
$: void updateTabItems(inboxData, $contextsStore) $: void updateTabItems(inboxData, $contextsStore)
async function updateTabItems (inboxData: InboxData, notifyContexts: DocNotifyContext[]): Promise<void> { async function updateTabItems (inboxData: InboxData, notifyContexts: DocNotifyContext[]): Promise<void> {
@ -258,15 +266,28 @@
void selectInboxContext(linkProviders, selectedContext, selectedNotification, event?.detail.object) void selectInboxContext(linkProviders, selectedContext, selectedNotification, event?.detail.object)
} }
function isChunterChannel (selectedContext: DocNotifyContext, urlObjectClass?: Ref<Class<Doc>>): boolean {
const isActivityMessageContext = hierarchy.isDerived(selectedContext.objectClass, activity.class.ActivityMessage)
const chunterClass = isActivityMessageContext
? urlObjectClass ?? selectedContext.objectClass
: selectedContext.objectClass
return hierarchy.isDerived(chunterClass, chunter.class.ChunterSpace)
}
async function updateSelectedPanel (selectedContext?: DocNotifyContext): Promise<void> { async function updateSelectedPanel (
selectedContext?: DocNotifyContext,
urlObjectClass?: Ref<Class<Doc>>
): Promise<void> {
if (selectedContext === undefined) { if (selectedContext === undefined) {
selectedComponent = undefined selectedComponent = undefined
return return
} }
const isChunterChannel = hierarchy.isDerived(selectedContext.objectClass, chunter.class.ChunterSpace) const isChunter = isChunterChannel(selectedContext, urlObjectClass)
const panelComponent = hierarchy.classHierarchyMixin(selectedContext.objectClass, view.mixin.ObjectPanel) const panelComponent = hierarchy.classHierarchyMixin(
isChunter ? urlObjectClass ?? selectedContext.objectClass : selectedContext.objectClass,
view.mixin.ObjectPanel
)
selectedComponent = panelComponent?.component ?? view.component.EditDoc selectedComponent = panelComponent?.component ?? view.component.EditDoc
@ -278,7 +299,7 @@
ops, ops,
contextNotifications contextNotifications
.filter(({ _class, isViewed }) => .filter(({ _class, isViewed }) =>
isChunterChannel ? _class === notification.class.CommonInboxNotification : !isViewed isChunter ? _class === notification.class.CommonInboxNotification : !isViewed
) )
.map(({ _id }) => _id) .map(({ _id }) => _id)
) )
@ -432,8 +453,12 @@
<Component <Component
is={selectedComponent} is={selectedComponent}
props={{ props={{
_id: selectedContext.objectId, _id: isChunterChannel(selectedContext, urlObjectClass)
_class: selectedContext.objectClass, ? urlObjectId ?? selectedContext.objectId
: selectedContext.objectId,
_class: isChunterChannel(selectedContext, urlObjectClass)
? urlObjectClass ?? selectedContext.objectClass
: selectedContext.objectClass,
context: selectedContext, context: selectedContext,
activityMessage: selectedMessage, activityMessage: selectedMessage,
props: { context: selectedContext } props: { context: selectedContext }

View File

@ -531,6 +531,7 @@ async function generateLocation (
async function navigateToInboxDoc ( async function navigateToInboxDoc (
providers: LinkIdProvider[], providers: LinkIdProvider[],
context: Ref<DocNotifyContext>,
_id?: Ref<Doc>, _id?: Ref<Doc>,
_class?: Ref<Class<Doc>>, _class?: Ref<Class<Doc>>,
thread?: Ref<ActivityMessage>, thread?: Ref<ActivityMessage>,
@ -559,7 +560,7 @@ async function navigateToInboxDoc (
loc.path.length = 4 loc.path.length = 4
} }
loc.query = { ...loc.query, message: message ?? null } loc.query = { ...loc.query, context, message: message ?? null }
messageInFocus.set(message) messageInFocus.set(message)
Analytics.handleEvent('inbox.ReadDoc', { objectId: id, objectClass: _class, thread, message }) Analytics.handleEvent('inbox.ReadDoc', { objectId: id, objectClass: _class, thread, message })
navigate(loc) navigate(loc)
@ -596,6 +597,7 @@ export async function selectInboxContext (
void navigateToInboxDoc( void navigateToInboxDoc(
linkProviders, linkProviders,
context._id,
objectId, objectId,
objectClass, objectClass,
isActivityMessageClass(objectClass) ? (objectId as Ref<ActivityMessage>) : undefined, isActivityMessageClass(objectClass) ? (objectId as Ref<ActivityMessage>) : undefined,
@ -621,6 +623,7 @@ export async function selectInboxContext (
void navigateToInboxDoc( void navigateToInboxDoc(
linkProviders, linkProviders,
context._id,
thread?.objectId ?? objectId, thread?.objectId ?? objectId,
thread?.objectClass ?? objectClass, thread?.objectClass ?? objectClass,
thread?.attachedTo, thread?.attachedTo,
@ -642,6 +645,7 @@ export async function selectInboxContext (
void navigateToInboxDoc( void navigateToInboxDoc(
linkProviders, linkProviders,
context._id,
channelId, channelId,
channelClass, channelClass,
thread as Ref<ActivityMessage>, thread as Ref<ActivityMessage>,
@ -657,6 +661,7 @@ export async function selectInboxContext (
void navigateToInboxDoc( void navigateToInboxDoc(
linkProviders, linkProviders,
context._id,
channelId, channelId,
channelClass, channelClass,
thread as Ref<ActivityMessage>, thread as Ref<ActivityMessage>,
@ -667,6 +672,7 @@ export async function selectInboxContext (
void navigateToInboxDoc( void navigateToInboxDoc(
linkProviders, linkProviders,
context._id,
objectId, objectId,
objectClass, objectClass,
undefined, undefined,