diff --git a/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomActivity.kt b/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomActivity.kt index 7b41c22607..82b8b812b4 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomActivity.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomActivity.kt @@ -22,6 +22,7 @@ import android.content.Context import android.content.Intent import android.os.Bundle import android.view.View +import androidx.appcompat.app.AlertDialog import androidx.lifecycle.ViewModelProviders import com.airbnb.mvrx.Fail import com.airbnb.mvrx.Loading @@ -30,6 +31,7 @@ import com.airbnb.mvrx.viewModel import com.google.android.gms.common.GooglePlayServicesNotAvailableException import im.vector.riotx.R import im.vector.riotx.core.di.ScreenComponent +import im.vector.riotx.core.error.ErrorFormatter import im.vector.riotx.core.extensions.addFragment import im.vector.riotx.core.extensions.addFragmentToBackstack import im.vector.riotx.core.extensions.observeEvent @@ -49,7 +51,7 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { private val viewModel: CreateDirectRoomViewModel by viewModel() lateinit var navigationViewModel: CreateDirectRoomNavigationViewModel @Inject lateinit var createDirectRoomViewModelFactory: CreateDirectRoomViewModel.Factory - + @Inject lateinit var errorFormatter: ErrorFormatter override fun injectWith(injector: ScreenComponent) { super.injectWith(injector) @@ -86,7 +88,11 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { } private fun renderCreationFailure(error: Throwable) { - + hideWaitingView() + AlertDialog.Builder(this) + .setMessage(errorFormatter.toHumanReadable(error)) + .setPositiveButton(R.string.ok) { dialog, id -> dialog.cancel() } + .show() } private fun renderCreationSuccess(roomId: String?) { diff --git a/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomViewModel.kt b/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomViewModel.kt index 87ee800532..481ca92253 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomViewModel.kt @@ -75,10 +75,10 @@ class CreateDirectRoomViewModel @AssistedInject constructor(@Assisted } } - private fun createRoomAndInviteSelectedUsers() = withState { - val isDirect = it.selectedUsers.size == 1 + private fun createRoomAndInviteSelectedUsers() = withState { currentState -> + val isDirect = currentState.selectedUsers.size == 1 val roomParams = CreateRoomParams().apply { - invitedUserIds = ArrayList(it.selectedUsers.map { user -> user.userId }) + invitedUserIds = ArrayList(currentState.selectedUsers.map { user -> user.userId }) if (isDirect) { setDirectMessage() }