Add confirmation check before ending a poll.

This commit is contained in:
Michelle Tang
2025-11-04 16:58:28 -05:00
parent e5b8262cfe
commit 800155e5a6
2 changed files with 23 additions and 12 deletions

View File

@@ -2663,19 +2663,26 @@ class ConversationFragment :
return
}
val endPoll = viewModel.endPoll(pollId)
MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.Poll__end_poll_title))
.setMessage(getString(R.string.Poll__end_poll_body))
.setPositiveButton(R.string.Poll__end_poll) { _, _ ->
val endPoll = viewModel.endPoll(pollId)
disposables += endPoll
.subscribeBy(
onError = {
Log.w(TAG, "Error received during poll end!", it)
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.Poll__couldnt_end_poll)
.setMessage(getString(R.string.Poll__check_connection))
.setPositiveButton(android.R.string.ok) { dialog: DialogInterface?, which: Int -> dialog!!.dismiss() }
.show()
}
)
disposables += endPoll
.subscribeBy(
onError = {
Log.w(TAG, "Error received during poll end!", it)
MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.Poll__couldnt_end_poll)
.setMessage(getString(R.string.Poll__check_connection))
.setPositiveButton(android.R.string.ok) { dialog: DialogInterface?, which: Int -> dialog!!.dismiss() }
.show()
}
)
}
.setNegativeButton(android.R.string.cancel) { _, _ -> }
.show()
}
private inner class SwipeAvailabilityProvider : ConversationItemSwipeCallback.SwipeAvailabilityProvider {

View File

@@ -8869,6 +8869,10 @@
<string name="Poll__couldnt_end_poll">Couldn\'t end poll</string>
<!-- Dialog body when a poll fails to end and to try again -->
<string name="Poll__check_connection">Check your connection and try again.</string>
<!-- Dialog title when you go to end a poll -->
<string name="Poll__end_poll_title">End poll?</string>
<!-- Dialog body when you go to end a poll -->
<string name="Poll__end_poll_body">Group members will no longer be able to vote in this poll.</string>
<!-- Header when creating a new poll -->
<string name="CreatePollFragment__new_poll">New poll</string>
<!-- Section text to enter in a question for a poll -->