mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 03:14:40 +03:00
Add chat and inbox fixes (#6779)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
47d14885e5
commit
99749f30fb
@ -40,6 +40,6 @@
|
||||
kind="tertiary"
|
||||
pressed={opened}
|
||||
{dataId}
|
||||
tooltip={{ label }}
|
||||
tooltip={{ label, direction: 'bottom' }}
|
||||
on:click={onClick}
|
||||
/>
|
||||
|
@ -81,7 +81,7 @@
|
||||
"Reacted": "Отреагировал(а)",
|
||||
"Docs": "Documents",
|
||||
"NewestFirst": "Сначала новые",
|
||||
"ReplyToThread": "Ответить в канале",
|
||||
"ReplyToThread": "Ответить в теме",
|
||||
"SentMessage": "Отправил(а) сообщение",
|
||||
"Direct": "Личные сообщения",
|
||||
"RepliedToThread": "Ответил(а) в канале",
|
||||
|
@ -379,7 +379,7 @@
|
||||
function messageInView (msgElement: Element, containerRect: DOMRect): boolean {
|
||||
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>()
|
||||
|
@ -151,7 +151,7 @@ export async function buildThreadLink (
|
||||
loc.path[2] = chunterId
|
||||
}
|
||||
|
||||
loc.query = { message: '' }
|
||||
loc.query = { ...loc.query, message: '' }
|
||||
loc.path[3] = objectURI
|
||||
loc.path[4] = threadParent
|
||||
loc.fragment = undefined
|
||||
|
@ -15,7 +15,7 @@
|
||||
<script lang="ts">
|
||||
import activity, { ActivityMessage } from '@hcengineering/activity'
|
||||
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 { ActionContext, createQuery, getClient } from '@hcengineering/presentation'
|
||||
import {
|
||||
@ -68,6 +68,9 @@
|
||||
|
||||
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 archivedActivityNotifications: InboxNotification[] = []
|
||||
let archivedOtherNotifications: InboxNotification[] = []
|
||||
@ -165,14 +168,19 @@
|
||||
|
||||
if (loc?.loc.path[3] == null) {
|
||||
selectedContext = undefined
|
||||
urlObjectId = undefined
|
||||
urlObjectClass = undefined
|
||||
restoreLocation(newLocation, notificationId)
|
||||
return
|
||||
}
|
||||
|
||||
const [id, _class] = decodeObjectURI(loc?.loc.path[3] ?? '')
|
||||
const _id = await parseLinkId(linkProviders, id, _class)
|
||||
urlObjectId = _id
|
||||
urlObjectClass = _class
|
||||
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
|
||||
|
||||
@ -199,7 +207,7 @@
|
||||
|
||||
$: selectedContext = selectedContextId ? selectedContext ?? $contextByIdStore.get(selectedContextId) : undefined
|
||||
|
||||
$: void updateSelectedPanel(selectedContext)
|
||||
$: void updateSelectedPanel(selectedContext, urlObjectClass)
|
||||
$: void updateTabItems(inboxData, $contextsStore)
|
||||
|
||||
async function updateTabItems (inboxData: InboxData, notifyContexts: DocNotifyContext[]): Promise<void> {
|
||||
@ -258,15 +266,28 @@
|
||||
|
||||
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) {
|
||||
selectedComponent = undefined
|
||||
return
|
||||
}
|
||||
|
||||
const isChunterChannel = hierarchy.isDerived(selectedContext.objectClass, chunter.class.ChunterSpace)
|
||||
const panelComponent = hierarchy.classHierarchyMixin(selectedContext.objectClass, view.mixin.ObjectPanel)
|
||||
const isChunter = isChunterChannel(selectedContext, urlObjectClass)
|
||||
const panelComponent = hierarchy.classHierarchyMixin(
|
||||
isChunter ? urlObjectClass ?? selectedContext.objectClass : selectedContext.objectClass,
|
||||
view.mixin.ObjectPanel
|
||||
)
|
||||
|
||||
selectedComponent = panelComponent?.component ?? view.component.EditDoc
|
||||
|
||||
@ -278,7 +299,7 @@
|
||||
ops,
|
||||
contextNotifications
|
||||
.filter(({ _class, isViewed }) =>
|
||||
isChunterChannel ? _class === notification.class.CommonInboxNotification : !isViewed
|
||||
isChunter ? _class === notification.class.CommonInboxNotification : !isViewed
|
||||
)
|
||||
.map(({ _id }) => _id)
|
||||
)
|
||||
@ -432,8 +453,12 @@
|
||||
<Component
|
||||
is={selectedComponent}
|
||||
props={{
|
||||
_id: selectedContext.objectId,
|
||||
_class: selectedContext.objectClass,
|
||||
_id: isChunterChannel(selectedContext, urlObjectClass)
|
||||
? urlObjectId ?? selectedContext.objectId
|
||||
: selectedContext.objectId,
|
||||
_class: isChunterChannel(selectedContext, urlObjectClass)
|
||||
? urlObjectClass ?? selectedContext.objectClass
|
||||
: selectedContext.objectClass,
|
||||
context: selectedContext,
|
||||
activityMessage: selectedMessage,
|
||||
props: { context: selectedContext }
|
||||
|
@ -531,6 +531,7 @@ async function generateLocation (
|
||||
|
||||
async function navigateToInboxDoc (
|
||||
providers: LinkIdProvider[],
|
||||
context: Ref<DocNotifyContext>,
|
||||
_id?: Ref<Doc>,
|
||||
_class?: Ref<Class<Doc>>,
|
||||
thread?: Ref<ActivityMessage>,
|
||||
@ -559,7 +560,7 @@ async function navigateToInboxDoc (
|
||||
loc.path.length = 4
|
||||
}
|
||||
|
||||
loc.query = { ...loc.query, message: message ?? null }
|
||||
loc.query = { ...loc.query, context, message: message ?? null }
|
||||
messageInFocus.set(message)
|
||||
Analytics.handleEvent('inbox.ReadDoc', { objectId: id, objectClass: _class, thread, message })
|
||||
navigate(loc)
|
||||
@ -596,6 +597,7 @@ export async function selectInboxContext (
|
||||
|
||||
void navigateToInboxDoc(
|
||||
linkProviders,
|
||||
context._id,
|
||||
objectId,
|
||||
objectClass,
|
||||
isActivityMessageClass(objectClass) ? (objectId as Ref<ActivityMessage>) : undefined,
|
||||
@ -621,6 +623,7 @@ export async function selectInboxContext (
|
||||
|
||||
void navigateToInboxDoc(
|
||||
linkProviders,
|
||||
context._id,
|
||||
thread?.objectId ?? objectId,
|
||||
thread?.objectClass ?? objectClass,
|
||||
thread?.attachedTo,
|
||||
@ -642,6 +645,7 @@ export async function selectInboxContext (
|
||||
|
||||
void navigateToInboxDoc(
|
||||
linkProviders,
|
||||
context._id,
|
||||
channelId,
|
||||
channelClass,
|
||||
thread as Ref<ActivityMessage>,
|
||||
@ -657,6 +661,7 @@ export async function selectInboxContext (
|
||||
|
||||
void navigateToInboxDoc(
|
||||
linkProviders,
|
||||
context._id,
|
||||
channelId,
|
||||
channelClass,
|
||||
thread as Ref<ActivityMessage>,
|
||||
@ -667,6 +672,7 @@ export async function selectInboxContext (
|
||||
|
||||
void navigateToInboxDoc(
|
||||
linkProviders,
|
||||
context._id,
|
||||
objectId,
|
||||
objectClass,
|
||||
undefined,
|
||||
|
Loading…
Reference in New Issue
Block a user