Add error toasts to multiforward sheet.

This commit is contained in:
Cody Henthorne
2022-08-23 19:24:45 -04:00
committed by Greyson Parrelli
parent 40c52a31c9
commit b57b160660
5 changed files with 36 additions and 3 deletions

View File

@@ -34,6 +34,7 @@ import org.thoughtcrime.securesms.components.ContactFilterView
import org.thoughtcrime.securesms.components.TooltipPopup
import org.thoughtcrime.securesms.components.WrapperDialogFragment
import org.thoughtcrime.securesms.contacts.paged.ContactSearchConfiguration
import org.thoughtcrime.securesms.contacts.paged.ContactSearchError
import org.thoughtcrime.securesms.contacts.paged.ContactSearchKey
import org.thoughtcrime.securesms.contacts.paged.ContactSearchMediator
import org.thoughtcrime.securesms.contacts.paged.ContactSearchState
@@ -197,6 +198,19 @@ class MultiselectForwardFragment :
}
}
disposables += contactSearchMediator
.getErrorEvents()
.subscribe {
@Suppress("WHEN_ENUM_CAN_BE_NULL_IN_JAVA")
val message: Int = when (it) {
ContactSearchError.CONTACT_NOT_SELECTABLE -> R.string.MultiselectForwardFragment__only_admins_can_send_messages_to_this_group
ContactSearchError.RECOMMENDED_LIMIT_REACHED -> R.string.ContactSelectionListFragment_recommended_member_limit_reached
ContactSearchError.HARD_LIMIT_REACHED -> R.string.MultiselectForwardFragment__limit_reached
}
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show()
}
viewModel.state.observe(viewLifecycleOwner) {
when (it.stage) {
MultiselectForwardState.Stage.Selection -> {}