From 6a810d959bde7d1c724c387a121c29a5ba36194c Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Thu, 18 Feb 2021 11:02:19 +1100 Subject: [PATCH] Fix initial scroll position bug --- Podfile.lock | 2 +- .../Conversations V2/ConversationVC+Interaction.swift | 1 + Session/Conversations V2/ConversationVC.swift | 11 ++++++----- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 503cc3094..3fc70a96b 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -218,4 +218,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 2fca3f32c171e1324c9e3809b96a32d4a929d05c -COCOAPODS: 1.10.1 +COCOAPODS: 1.10.0.rc.1 diff --git a/Session/Conversations V2/ConversationVC+Interaction.swift b/Session/Conversations V2/ConversationVC+Interaction.swift index 3a9a58e7f..5209835eb 100644 --- a/Session/Conversations V2/ConversationVC+Interaction.swift +++ b/Session/Conversations V2/ConversationVC+Interaction.swift @@ -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) { } } diff --git a/Session/Conversations V2/ConversationVC.swift b/Session/Conversations V2/ConversationVC.swift index 417a56a98..800f55446 100644 --- a/Session/Conversations V2/ConversationVC.swift +++ b/Session/Conversations V2/ConversationVC.swift @@ -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() }