Fix chat loading problems (#5899)

This commit is contained in:
Kristina 2024-06-22 08:11:45 +04:00 committed by GitHub
parent 32861f2f33
commit a468c6705a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 15 deletions

View File

@ -197,7 +197,7 @@ export class ChannelDataProvider implements IChannelDataProvider {
const startPosition = this.getStartPosition(selectedMsg ?? this.selectedMsgId, firstNewMsgIndex) const startPosition = this.getStartPosition(selectedMsg ?? this.selectedMsgId, firstNewMsgIndex)
const count = metadata.length const count = metadata.length
const isLoadingLatest = startPosition === undefined || startPosition === -1 const isLoadingLatest = startPosition === undefined || startPosition === -1 || count - startPosition <= this.limit
if (loadAll) { if (loadAll) {
this.loadTail(undefined, combineActivityMessages) this.loadTail(undefined, combineActivityMessages)
@ -206,20 +206,9 @@ export class ChannelDataProvider implements IChannelDataProvider {
this.isTailLoading.set(true) this.isTailLoading.set(true)
const tailStart = metadata[startIndex]?.createdOn const tailStart = metadata[startIndex]?.createdOn
this.loadTail(tailStart) this.loadTail(tailStart)
} else if (count - startPosition <= this.limit) {
this.isTailLoading.set(true)
const tailStart = metadata[startPosition]?.createdOn
this.loadTail(tailStart)
await this.loadMore('backward', tailStart)
} else { } else {
const start = metadata[startPosition]?.createdOn const newStart = Math.max(startPosition - this.limit / 2, 0)
await this.loadMore('forward', metadata[newStart]?.createdOn, this.limit)
if (startPosition === 0) {
await this.loadMore('forward', metadata[startPosition]?.createdOn, this.limit)
} else {
await this.loadMore('backward', start, this.limit / 2)
await this.loadMore('forward', metadata[startPosition - 1]?.createdOn, this.limit / 2)
}
} }
this.isInitialLoadingStore.set(false) this.isInitialLoadingStore.set(false)

View File

@ -236,7 +236,7 @@
const { scrollHeight, scrollTop, clientHeight } = scrollElement const { scrollHeight, scrollTop, clientHeight } = scrollElement
return Math.ceil(scrollTop + clientHeight) === scrollHeight return scrollHeight - Math.ceil(scrollTop + clientHeight) <= 0
} }
let scrollToRestore = 0 let scrollToRestore = 0

View File

@ -32,6 +32,9 @@
let object: Doc | undefined = undefined let object: Doc | undefined = undefined
$: if (object?._id !== value.attachedTo) {
object = undefined
}
$: iconMixin = hierarchy.classHierarchyMixin(value.attachedToClass, view.mixin.ObjectIcon) $: iconMixin = hierarchy.classHierarchyMixin(value.attachedToClass, view.mixin.ObjectIcon)
$: iconMixin && $: iconMixin &&
query.query(value.attachedToClass, { _id: value.attachedTo }, (res) => { query.query(value.attachedToClass, { _id: value.attachedTo }, (res) => {

View File

@ -232,6 +232,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
) )
for (const notification of notificationsToRead) { for (const notification of notificationsToRead) {
notification.isViewed = true
await client.update(notification, { isViewed: true }) await client.update(notification, { isViewed: true })
} }
} }