From d833bbc44cfbbcceb6e4ed41404c7c4f94454405 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Tue, 23 Feb 2021 11:28:22 +1100 Subject: [PATCH] Hide input view after user left group --- Session/Conversations/ConversationVC.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index c74aba0d2..c2ea6dccc 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -33,8 +33,15 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat var audioSession: OWSAudioSession { Environment.shared.audioSession } var dbConnection: YapDatabaseConnection { OWSPrimaryStorage.shared().uiDatabaseConnection } var viewItems: [ConversationViewItem] { viewModel.viewState.viewItems } - override var inputAccessoryView: UIView? { isShowingSearchUI ? searchController.resultsBar : snInputView } override var canBecomeFirstResponder: Bool { true } + + override var inputAccessoryView: UIView? { + if let thread = thread as? TSGroupThread, thread.groupModel.groupType == .closedGroup && !thread.isCurrentUserMemberInGroup() { + return nil + } else { + return isShowingSearchUI ? searchController.resultsBar : snInputView + } + } var tableViewUnobscuredHeight: CGFloat { let bottomInset = messagesTableView.adjustedContentInset.bottom @@ -135,6 +142,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat notificationCenter.addObserver(self, selector: #selector(handleKeyboardWillHideNotification(_:)), name: UIResponder.keyboardWillHideNotification, object: nil) notificationCenter.addObserver(self, selector: #selector(handleAudioDidFinishPlayingNotification(_:)), name: .SNAudioDidFinishPlaying, object: nil) notificationCenter.addObserver(self, selector: #selector(addOrRemoveBlockedBanner), name: NSNotification.Name(rawValue: kNSNotificationName_BlockListDidChange), object: nil) + notificationCenter.addObserver(self, selector: #selector(handleGroupUpdatedNotification), name: .groupThreadUpdated, object: nil) // Mentions MentionsManager.populateUserPublicKeyCacheIfNeeded(for: thread.uniqueId!) } @@ -312,6 +320,11 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat } + @objc private func handleGroupUpdatedNotification() { + thread.reload() + reloadInputViews() + } + // MARK: General @objc func addOrRemoveBlockedBanner() { func detach() {