Browse Source

scoll to top of first fresh message, not the one above

cyberta 4 years ago
parent
commit
9e2d4b45f8
1 changed files with 2 additions and 2 deletions
  1. 2 2
      deltachat-ios/Chat/ChatViewController.swift

+ 2 - 2
deltachat-ios/Chat/ChatViewController.swift

@@ -812,8 +812,8 @@ class ChatViewController: UITableViewController {
         DispatchQueue.main.async { [weak self] in
         DispatchQueue.main.async { [weak self] in
             guard let self = self else { return }
             guard let self = self else { return }
             let freshMsgsCount = self.dcContext.getFreshMessagesCount(chatId: self.chatId)
             let freshMsgsCount = self.dcContext.getFreshMessagesCount(chatId: self.chatId)
-            if self.messageIds.count >= freshMsgsCount {
-                let index = self.messageIds.count - freshMsgsCount - 1
+            if freshMsgsCount > 0 && self.messageIds.count >= freshMsgsCount {
+                let index = self.messageIds.count - freshMsgsCount
                 let indexPath = IndexPath(row: index, section: 0)
                 let indexPath = IndexPath(row: index, section: 0)
                 self.tableView.scrollToRow(at: indexPath, at: .top, animated: false)
                 self.tableView.scrollToRow(at: indexPath, at: .top, animated: false)
             } else {
             } else {