Fix initial scroll position bug

This commit is contained in:
Niels Andriesse 2021-02-18 11:02:19 +11:00
parent 907925496f
commit 6a810d959b
3 changed files with 8 additions and 6 deletions

View File

@ -218,4 +218,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 2fca3f32c171e1324c9e3809b96a32d4a929d05c
COCOAPODS: 1.10.1
COCOAPODS: 1.10.0.rc.1

View File

@ -96,6 +96,7 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
let gifVC = GifPickerViewController(thread: thread)
gifVC.delegate = self
let navController = OWSNavigationController(rootViewController: gifVC)
navController.modalPresentationStyle = .fullScreen
present(navController, animated: true) { }
}

View File

@ -1,7 +1,6 @@
// TODO
// Tapping replies
// Initial scroll position
// Moderator icons
// Slight paging glitch
// Image detail VC transition glitch
@ -27,7 +26,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, UITableViewD
var mentions: [Mention] = []
// Scrolling & paging
private var isUserScrolling = false
private var hasPerformedInitialScroll = false
private var didFinishInitialLayout = false
private var isLoadingMore = false
private var scrollDistanceToBottomBeforeUpdate: CGFloat?
@ -132,14 +131,16 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, UITableViewD
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
if !hasPerformedInitialScroll {
scrollToBottom(isAnimated: false)
hasPerformedInitialScroll = true
if !didFinishInitialLayout {
DispatchQueue.main.async {
self.scrollToBottom(isAnimated: false)
}
}
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
didFinishInitialLayout = true
markAllAsRead()
}