[go: nahoru, domu]

Skip to content

Commit

Permalink
Fix chat loading problems (hcengineering#5899)
Browse files Browse the repository at this point in the history
  • Loading branch information
kristina-fefelova committed Jun 22, 2024
1 parent 32861f2 commit a468c67
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
17 changes: 3 additions & 14 deletions plugins/chunter-resources/src/channelDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class ChannelDataProvider implements IChannelDataProvider {
const startPosition = this.getStartPosition(selectedMsg ?? this.selectedMsgId, firstNewMsgIndex)

const count = metadata.length
const isLoadingLatest = startPosition === undefined || startPosition === -1
const isLoadingLatest = startPosition === undefined || startPosition === -1 || count - startPosition <= this.limit

if (loadAll) {
this.loadTail(undefined, combineActivityMessages)
Expand All @@ -206,20 +206,9 @@ export class ChannelDataProvider implements IChannelDataProvider {
this.isTailLoading.set(true)
const tailStart = metadata[startIndex]?.createdOn
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 {
const start = metadata[startPosition]?.createdOn

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)
}
const newStart = Math.max(startPosition - this.limit / 2, 0)
await this.loadMore('forward', metadata[newStart]?.createdOn, this.limit)
}

this.isInitialLoadingStore.set(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
const { scrollHeight, scrollTop, clientHeight } = scrollElement
return Math.ceil(scrollTop + clientHeight) === scrollHeight
return scrollHeight - Math.ceil(scrollTop + clientHeight) <= 0
}
let scrollToRestore = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
let object: Doc | undefined = undefined
$: if (object?._id !== value.attachedTo) {
object = undefined
}
$: iconMixin = hierarchy.classHierarchyMixin(value.attachedToClass, view.mixin.ObjectIcon)
$: iconMixin &&
query.query(value.attachedToClass, { _id: value.attachedTo }, (res) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export class InboxNotificationsClientImpl implements InboxNotificationsClient {
)

for (const notification of notificationsToRead) {
notification.isViewed = true
await client.update(notification, { isViewed: true })
}
}
Expand Down

0 comments on commit a468c67

Please sign in to comment.