mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
fix unread bellow and stop fetching on chat open scroll
This commit is contained in:
@@ -524,7 +524,7 @@ struct ChatView: View {
|
||||
-1
|
||||
}
|
||||
|
||||
let unreadBelow =
|
||||
var unreadBelow =
|
||||
if bottomItemIndex != -1 {
|
||||
im.reversedChatItems[..<bottomItemIndex].reduce(into: 0) { unread, chatItem in
|
||||
if chatItem.isRcvNew { unread += 1 }
|
||||
@@ -532,6 +532,9 @@ struct ChatView: View {
|
||||
} else {
|
||||
0
|
||||
}
|
||||
if unreadBelow > 0, let g = im.gap, g.size > 0, g.index < bottomItemIndex {
|
||||
unreadBelow += g.size
|
||||
}
|
||||
let date: Date? =
|
||||
if let topItemDate = listState.topItemDate {
|
||||
Calendar.current.startOfDay(for: topItemDate)
|
||||
|
||||
@@ -82,13 +82,12 @@ struct ReverseList<Content: View>: UIViewControllerRepresentable {
|
||||
self.dataSource = UITableViewDiffableDataSource<Section, ChatItem>(
|
||||
tableView: tableView
|
||||
) { (tableView, indexPath, item) -> UITableViewCell? in
|
||||
if self.representer.scrollState == .atDestination {
|
||||
if self.representer.scrollState == .atDestination, self.representer.initialChatItem == nil {
|
||||
if indexPath.item > self.itemCount - preloadItem, let item = self.getItemAtPath(indexPath: IndexPath(row: self.itemCount - 1, section: 0)) {
|
||||
self.representer.loadPage(.before(chatItemId: item.id, count: loadItemsPerPage))
|
||||
} else if let item = self.getFirstItemBeforePlacholder(indexPath) {
|
||||
// TODO: Cleanup, this should never be possible
|
||||
} else if let item = self.getFirstItemAfterPlacholder(indexPath) {
|
||||
logger.error("[scrolling] needs items in bottom \(item.text)")
|
||||
self.representer.loadPage(.after(chatItemId: item.id, count: loadItemsPerPage))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user