mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 11:42:30 +03:00
Chat fixes (#4947)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
97d03c38ee
commit
f2b4176db3
@ -52,7 +52,7 @@
|
||||
export let isAsideOpened = false
|
||||
|
||||
const dateSelectorHeight = 30
|
||||
const headerHeight = 50
|
||||
const headerHeight = 52
|
||||
const minMsgHeightRem = 4.375
|
||||
|
||||
const client = getClient()
|
||||
@ -316,10 +316,9 @@
|
||||
return
|
||||
}
|
||||
|
||||
const reversedMessages = [...displayMessages].reverse()
|
||||
const reversedDates = [...get(datesStore)].reverse()
|
||||
|
||||
for (const message of reversedMessages) {
|
||||
for (const message of displayMessages) {
|
||||
const msgElement = messagesElements?.[message._id as any]
|
||||
|
||||
if (!msgElement) {
|
||||
@ -332,12 +331,37 @@
|
||||
continue
|
||||
}
|
||||
|
||||
if (messageInView(msgElement, containerRect)) {
|
||||
const messageRect = msgElement.getBoundingClientRect()
|
||||
|
||||
const isInView =
|
||||
messageRect.top > 0 &&
|
||||
messageRect.top < containerRect.bottom &&
|
||||
messageRect.bottom - headerHeight - 2 * dateSelectorHeight > 0 &&
|
||||
messageRect.bottom <= containerRect.bottom
|
||||
|
||||
if (isInView) {
|
||||
selectedDate = reversedDates.find((date) => date <= createdOn)
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedDate) {
|
||||
const day = getDay(selectedDate)
|
||||
const dateElement = document.getElementById(day.toString())
|
||||
|
||||
let isElementVisible = false
|
||||
|
||||
if (dateElement) {
|
||||
const elementRect = dateElement.getBoundingClientRect()
|
||||
isElementVisible =
|
||||
elementRect.top + dateSelectorHeight / 2 >= containerRect.top && elementRect.bottom <= containerRect.bottom
|
||||
}
|
||||
|
||||
if (isElementVisible) {
|
||||
selectedDate = undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$: void initializeScroll($isLoadingStore, separatorElement, $newTimestampStore)
|
||||
@ -379,9 +403,10 @@
|
||||
shouldWaitAndRead = false
|
||||
onComplete?.()
|
||||
} else if (shouldWaitAndRead && messages.length > 0) {
|
||||
shouldWaitAndRead = false
|
||||
setTimeout(() => {
|
||||
waitLastMessageRenderAndRead(onComplete)
|
||||
}, 50)
|
||||
}, 500)
|
||||
} else {
|
||||
onComplete?.()
|
||||
}
|
||||
@ -514,8 +539,8 @@
|
||||
{#if startFromBottom}
|
||||
<div class="grower" />
|
||||
{/if}
|
||||
{#if withDates && displayMessages.length > 0}
|
||||
<div class="ml-2 pr-2">
|
||||
{#if withDates && displayMessages.length > 0 && selectedDate}
|
||||
<div class="selectedDate">
|
||||
<JumpToDateSelector {selectedDate} fixed on:jumpToDate={jumpToDate} />
|
||||
</div>
|
||||
{/if}
|
||||
@ -606,4 +631,11 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.selectedDate {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
</style>
|
||||
|
@ -258,9 +258,14 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
||||
|
||||
try {
|
||||
const inboxNotifications = get(this.inboxNotifications) ?? []
|
||||
const contexts = get(this.docNotifyContexts) ?? []
|
||||
for (const notification of inboxNotifications) {
|
||||
await ops.remove(notification)
|
||||
}
|
||||
|
||||
for (const context of contexts) {
|
||||
await ops.update(context, { lastViewedTimestamp: Date.now() })
|
||||
}
|
||||
} finally {
|
||||
await ops.commit()
|
||||
await doneOp()
|
||||
@ -273,11 +278,15 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
||||
|
||||
try {
|
||||
const inboxNotifications = get(this.inboxNotifications) ?? []
|
||||
const contexts = get(this.docNotifyContexts) ?? []
|
||||
for (const notification of inboxNotifications) {
|
||||
if (!notification.isViewed) {
|
||||
await ops.update(notification, { isViewed: true })
|
||||
}
|
||||
}
|
||||
for (const context of contexts) {
|
||||
await ops.update(context, { lastViewedTimestamp: Date.now() })
|
||||
}
|
||||
} finally {
|
||||
await ops.commit()
|
||||
await doneOp()
|
||||
@ -290,11 +299,16 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
||||
|
||||
try {
|
||||
const inboxNotifications = get(this.inboxNotifications) ?? []
|
||||
const contexts = get(this.docNotifyContexts) ?? []
|
||||
|
||||
for (const notification of inboxNotifications) {
|
||||
if (notification.isViewed) {
|
||||
await ops.update(notification, { isViewed: false })
|
||||
}
|
||||
}
|
||||
for (const context of contexts) {
|
||||
await ops.update(context, { lastViewedTimestamp: 0 })
|
||||
}
|
||||
} finally {
|
||||
await ops.commit()
|
||||
await doneOp()
|
||||
|
@ -88,7 +88,7 @@
|
||||
(res) => {
|
||||
messages = res.reverse()
|
||||
if (channel !== undefined) {
|
||||
inboxClient.forceReadDoc(channel._id, channel._class)
|
||||
inboxClient.forceReadDoc(client, channel._id, channel._class)
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -149,7 +149,7 @@
|
||||
}
|
||||
)
|
||||
if (channel !== undefined) {
|
||||
await inboxClient.forceReadDoc(channel._id, channel._class)
|
||||
await inboxClient.forceReadDoc(client, channel._id, channel._class)
|
||||
}
|
||||
clear()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user