Browse Source

fixed scroll to bottom condition in viewWillTransition completion block

nayooti 5 years ago
parent
commit
3ab2321c39
1 changed files with 3 additions and 2 deletions
  1. 3 2
      deltachat-ios/Controller/ChatViewController.swift

+ 3 - 2
deltachat-ios/Controller/ChatViewController.swift

@@ -233,6 +233,7 @@ class ChatViewController: MessagesViewController {
     }
 
     override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+        let lastSectionVisibleBeforeTransition = self.isLastSectionVisible()
         coordinator.animate(
             alongsideTransition: { _ in
                 if self.showCustomNavBar, let titleView = self.navigationItem.titleView as? ChatTitleView {
@@ -242,8 +243,8 @@ class ChatViewController: MessagesViewController {
             completion: { _ in
                 self.updateTitle(chat: DcChat(id: self.chatId))
                 self.messagesCollectionView.reloadDataAndKeepOffset()
-                if self.isLastSectionVisible() {
-                    self.messagesCollectionView.scrollToBottom(animated: true)
+                if lastSectionVisibleBeforeTransition {
+                    self.messagesCollectionView.scrollToBottom(animated: false)
                 }
             }
         )