mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-25 19:58: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
|
export let isAsideOpened = false
|
||||||
|
|
||||||
const dateSelectorHeight = 30
|
const dateSelectorHeight = 30
|
||||||
const headerHeight = 50
|
const headerHeight = 52
|
||||||
const minMsgHeightRem = 4.375
|
const minMsgHeightRem = 4.375
|
||||||
|
|
||||||
const client = getClient()
|
const client = getClient()
|
||||||
@ -316,10 +316,9 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const reversedMessages = [...displayMessages].reverse()
|
|
||||||
const reversedDates = [...get(datesStore)].reverse()
|
const reversedDates = [...get(datesStore)].reverse()
|
||||||
|
|
||||||
for (const message of reversedMessages) {
|
for (const message of displayMessages) {
|
||||||
const msgElement = messagesElements?.[message._id as any]
|
const msgElement = messagesElements?.[message._id as any]
|
||||||
|
|
||||||
if (!msgElement) {
|
if (!msgElement) {
|
||||||
@ -332,12 +331,37 @@
|
|||||||
continue
|
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)
|
selectedDate = reversedDates.find((date) => date <= createdOn)
|
||||||
|
|
||||||
break
|
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)
|
$: void initializeScroll($isLoadingStore, separatorElement, $newTimestampStore)
|
||||||
@ -379,9 +403,10 @@
|
|||||||
shouldWaitAndRead = false
|
shouldWaitAndRead = false
|
||||||
onComplete?.()
|
onComplete?.()
|
||||||
} else if (shouldWaitAndRead && messages.length > 0) {
|
} else if (shouldWaitAndRead && messages.length > 0) {
|
||||||
|
shouldWaitAndRead = false
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
waitLastMessageRenderAndRead(onComplete)
|
waitLastMessageRenderAndRead(onComplete)
|
||||||
}, 50)
|
}, 500)
|
||||||
} else {
|
} else {
|
||||||
onComplete?.()
|
onComplete?.()
|
||||||
}
|
}
|
||||||
@ -514,8 +539,8 @@
|
|||||||
{#if startFromBottom}
|
{#if startFromBottom}
|
||||||
<div class="grower" />
|
<div class="grower" />
|
||||||
{/if}
|
{/if}
|
||||||
{#if withDates && displayMessages.length > 0}
|
{#if withDates && displayMessages.length > 0 && selectedDate}
|
||||||
<div class="ml-2 pr-2">
|
<div class="selectedDate">
|
||||||
<JumpToDateSelector {selectedDate} fixed on:jumpToDate={jumpToDate} />
|
<JumpToDateSelector {selectedDate} fixed on:jumpToDate={jumpToDate} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
@ -606,4 +631,11 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.selectedDate {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -258,9 +258,14 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const inboxNotifications = get(this.inboxNotifications) ?? []
|
const inboxNotifications = get(this.inboxNotifications) ?? []
|
||||||
|
const contexts = get(this.docNotifyContexts) ?? []
|
||||||
for (const notification of inboxNotifications) {
|
for (const notification of inboxNotifications) {
|
||||||
await ops.remove(notification)
|
await ops.remove(notification)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const context of contexts) {
|
||||||
|
await ops.update(context, { lastViewedTimestamp: Date.now() })
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await ops.commit()
|
await ops.commit()
|
||||||
await doneOp()
|
await doneOp()
|
||||||
@ -273,11 +278,15 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const inboxNotifications = get(this.inboxNotifications) ?? []
|
const inboxNotifications = get(this.inboxNotifications) ?? []
|
||||||
|
const contexts = get(this.docNotifyContexts) ?? []
|
||||||
for (const notification of inboxNotifications) {
|
for (const notification of inboxNotifications) {
|
||||||
if (!notification.isViewed) {
|
if (!notification.isViewed) {
|
||||||
await ops.update(notification, { isViewed: true })
|
await ops.update(notification, { isViewed: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const context of contexts) {
|
||||||
|
await ops.update(context, { lastViewedTimestamp: Date.now() })
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await ops.commit()
|
await ops.commit()
|
||||||
await doneOp()
|
await doneOp()
|
||||||
@ -290,11 +299,16 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const inboxNotifications = get(this.inboxNotifications) ?? []
|
const inboxNotifications = get(this.inboxNotifications) ?? []
|
||||||
|
const contexts = get(this.docNotifyContexts) ?? []
|
||||||
|
|
||||||
for (const notification of inboxNotifications) {
|
for (const notification of inboxNotifications) {
|
||||||
if (notification.isViewed) {
|
if (notification.isViewed) {
|
||||||
await ops.update(notification, { isViewed: false })
|
await ops.update(notification, { isViewed: false })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const context of contexts) {
|
||||||
|
await ops.update(context, { lastViewedTimestamp: 0 })
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
await ops.commit()
|
await ops.commit()
|
||||||
await doneOp()
|
await doneOp()
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
(res) => {
|
(res) => {
|
||||||
messages = res.reverse()
|
messages = res.reverse()
|
||||||
if (channel !== undefined) {
|
if (channel !== undefined) {
|
||||||
inboxClient.forceReadDoc(channel._id, channel._class)
|
inboxClient.forceReadDoc(client, channel._id, channel._class)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -149,7 +149,7 @@
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
if (channel !== undefined) {
|
if (channel !== undefined) {
|
||||||
await inboxClient.forceReadDoc(channel._id, channel._class)
|
await inboxClient.forceReadDoc(client, channel._id, channel._class)
|
||||||
}
|
}
|
||||||
clear()
|
clear()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user