Fix HomeList error snackbar and add dialog for bottom sheet errors
This commit is contained in:
parent
cd424b0766
commit
f8114dd7a1
|
@ -143,7 +143,7 @@ android {
|
|||
resValue "bool", "useLoginV2", "false"
|
||||
|
||||
// NotificationSettingsV2 is disabled. To be released in conjunction with iOS/Web
|
||||
def useNotificationSettingsV2 = false
|
||||
def useNotificationSettingsV2 = true
|
||||
buildConfigField "Boolean", "USE_NOTIFICATION_SETTINGS_V2", "${useNotificationSettingsV2}"
|
||||
resValue "bool", "useNotificationSettingsV1", "${!useNotificationSettingsV2}"
|
||||
resValue "bool", "useNotificationSettingsV2", "${useNotificationSettingsV2}"
|
||||
|
|
|
@ -143,6 +143,8 @@ class HomeActivity :
|
|||
}
|
||||
}
|
||||
|
||||
override fun getCoordinatorLayout() = views.coordinatorLayout
|
||||
|
||||
override fun getBinding() = ActivityHomeBinding.inflate(layoutInflater)
|
||||
|
||||
override fun injectWith(injector: ScreenComponent) {
|
||||
|
|
|
@ -473,16 +473,9 @@ class RoomListFragment @Inject constructor(
|
|||
// refresh footer
|
||||
footerController.setData(it)
|
||||
}
|
||||
val bottomSheet = RoomListQuickActionsBottomSheet
|
||||
RoomListQuickActionsBottomSheet
|
||||
.newInstance(room.roomId, RoomListActionsArgs.Mode.FULL)
|
||||
bottomSheet.listener = object : RoomListQuickActionsBottomSheet.Listener {
|
||||
override fun handleFailure(throwable: Throwable) {
|
||||
showFailure(throwable)
|
||||
}
|
||||
}
|
||||
|
||||
bottomSheet.show(childFragmentManager, "ROOM_LIST_QUICK_ACTIONS")
|
||||
|
||||
.show(childFragmentManager, "ROOM_LIST_QUICK_ACTIONS")
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,14 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.airbnb.mvrx.args
|
||||
import com.airbnb.mvrx.fragmentViewModel
|
||||
import com.airbnb.mvrx.withState
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
import im.vector.app.core.extensions.cleanup
|
||||
import im.vector.app.core.extensions.configureWith
|
||||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
||||
import im.vector.app.core.platform.showOptimizedSnackbar
|
||||
import im.vector.app.databinding.BottomSheetGenericListBinding
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
import im.vector.app.features.roomprofile.notifications.RoomNotificationSettingsAction
|
||||
|
@ -57,20 +61,17 @@ class RoomListQuickActionsBottomSheet :
|
|||
VectorBaseBottomSheetDialogFragment<BottomSheetGenericListBinding>(),
|
||||
RoomListQuickActionsEpoxyController.Listener {
|
||||
|
||||
interface Listener {
|
||||
fun handleFailure(throwable: Throwable)
|
||||
}
|
||||
private lateinit var sharedActionViewModel: RoomListQuickActionsSharedActionViewModel
|
||||
@Inject lateinit var sharedViewPool: RecyclerView.RecycledViewPool
|
||||
@Inject lateinit var roomNotificationSettingsViewModelFactory: RoomNotificationSettingsViewModel.Factory
|
||||
@Inject lateinit var roomListActionsEpoxyController: RoomListQuickActionsEpoxyController
|
||||
@Inject lateinit var navigator: Navigator
|
||||
@Inject lateinit var errorFormatter: ErrorFormatter
|
||||
|
||||
private val roomListActionsArgs: RoomListActionsArgs by args()
|
||||
private val viewModel: RoomNotificationSettingsViewModel by fragmentViewModel(RoomNotificationSettingsViewModel::class)
|
||||
|
||||
override val showExpanded = true
|
||||
var listener: Listener? = null
|
||||
|
||||
override fun injectWith(injector: ScreenComponent) {
|
||||
injector.inject(this)
|
||||
|
@ -93,7 +94,7 @@ class RoomListQuickActionsBottomSheet :
|
|||
|
||||
viewModel.observeViewEvents {
|
||||
when (it) {
|
||||
is RoomNotificationSettingsViewEvents.Failure -> listener?.handleFailure(it.throwable)
|
||||
is RoomNotificationSettingsViewEvents.Failure -> displayErrorDialog(it.throwable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,4 +135,12 @@ class RoomListQuickActionsBottomSheet :
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun displayErrorDialog(throwable: Throwable) {
|
||||
MaterialAlertDialogBuilder(requireActivity())
|
||||
.setTitle(R.string.dialog_title_error)
|
||||
.setMessage(errorFormatter.toHumanReadable(throwable))
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue