Fix back navigation stuck in conversation after activity recreation.

Co-authored-by: Greyson Parrelli <greyson@signal.org>
This commit is contained in:
Alex Hart
2026-03-30 14:13:58 -03:00
parent 5a91dba56e
commit 2c98bbaf7e
2 changed files with 13 additions and 1 deletions

View File

@@ -650,6 +650,7 @@ class ConversationFragment :
} }
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
viewModel.resetBackPressedState()
binding.toolbar.isBackInvokedCallbackEnabled = false binding.toolbar.isBackInvokedCallbackEnabled = false
binding.root.setUseWindowTypes(args.conversationScreenType == ConversationScreenType.NORMAL && !resources.getWindowSizeClass().isSplitPane()) binding.root.setUseWindowTypes(args.conversationScreenType == ConversationScreenType.NORMAL && !resources.getWindowSizeClass().isSplitPane())
if (args.conversationScreenType == ConversationScreenType.BUBBLE) { if (args.conversationScreenType == ConversationScreenType.BUBBLE) {
@@ -1042,7 +1043,14 @@ class ConversationFragment :
state.isInActionMode -> finishActionMode() state.isInActionMode -> finishActionMode()
state.isMediaKeyboardShowing -> container.hideInput() state.isMediaKeyboardShowing -> {
if (container.isInputShowing) {
container.hideInput()
} else {
Log.d(TAG, "handleBackPressed() - media keyboard state was stale, clearing")
viewModel.setIsMediaKeyboardShowing(false)
}
}
else -> { else -> {
// State has changed since the back handler was enabled. Let the back press proceed // State has changed since the back handler was enabled. Let the back press proceed

View File

@@ -733,6 +733,10 @@ class ConversationViewModel(
} }
} }
fun resetBackPressedState() {
internalBackPressedState.value = BackPressedState()
}
fun toggleVote(poll: PollRecord, pollOption: PollOption, isChecked: Boolean) { fun toggleVote(poll: PollRecord, pollOption: PollOption, isChecked: Boolean) {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
val voteCount = if (isChecked) { val voteCount = if (isChecked) {