From 102a29b8e34e182e97318ec57a7c9c20651ed9ae Mon Sep 17 00:00:00 2001 From: Ryan Zhao Date: Tue, 26 Apr 2022 11:51:55 +1000 Subject: [PATCH] further fix for input view not scrollable issue --- .../Context Menu/ContextMenuVC+Action.swift | 1 + .../Conversations/Context Menu/ContextMenuVC.swift | 1 + .../Conversations/ConversationVC+Interaction.swift | 4 ++++ Session/Conversations/ConversationVC.swift | 13 ++++++++++--- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Session/Conversations/Context Menu/ContextMenuVC+Action.swift b/Session/Conversations/Context Menu/ContextMenuVC+Action.swift index 57d0168e6..d7eaaae65 100644 --- a/Session/Conversations/Context Menu/ContextMenuVC+Action.swift +++ b/Session/Conversations/Context Menu/ContextMenuVC+Action.swift @@ -95,4 +95,5 @@ protocol ContextMenuActionDelegate : AnyObject { func save(_ viewItem: ConversationViewItem) func ban(_ viewItem: ConversationViewItem) func banAndDeleteAllMessages(_ viewItem: ConversationViewItem) + func contextMenuDismissed() } diff --git a/Session/Conversations/Context Menu/ContextMenuVC.swift b/Session/Conversations/Context Menu/ContextMenuVC.swift index 66cf13925..376022914 100644 --- a/Session/Conversations/Context Menu/ContextMenuVC.swift +++ b/Session/Conversations/Context Menu/ContextMenuVC.swift @@ -132,6 +132,7 @@ final class ContextMenuVC : UIViewController { self.timestampLabel.alpha = 0 }, completion: { _ in self.dismiss() + self.delegate?.contextMenuDismissed() }) } } diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index 965f25572..b09cded86 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -785,6 +785,10 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc alert.addAction(UIAlertAction(title: "Cancel", style: .default, handler: nil)) present(alert, animated: true, completion: nil) } + + func contextMenuDismissed() { + recoverInputView() + } func handleQuoteViewCancelButtonTapped() { snInputView.quoteDraftInfo = nil diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index e75f42eec..1e6e06348 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -425,6 +425,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat highlightFocusedMessageIfNeeded() didFinishInitialLayout = true markAllAsRead() + recoverInputView() } override func viewWillDisappear(_ animated: Bool) { @@ -442,9 +443,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat } override func appDidBecomeActive(_ notification: Notification) { - // This is a workaround for an issue where the textview is not scrollable - // after the app goes into background and goes back in foreground. - self.snInputView.text = self.snInputView.text + recoverInputView() } deinit { @@ -737,6 +736,14 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat } } + func recoverInputView() { + // This is a workaround for an issue where the textview is not scrollable + // after the app goes into background and goes back in foreground. + DispatchQueue.main.async { + self.snInputView.text = self.snInputView.text + } + } + func markAllAsRead() { guard let lastSortID = viewItems.last?.interaction.sortId else { return } OWSReadReceiptManager.shared().markAsReadLocally(