code review

This commit is contained in:
Valere 2020-11-25 18:02:01 +01:00
parent 8e6e6736a3
commit 4f5632b916
2 changed files with 23 additions and 24 deletions

View File

@ -125,9 +125,9 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
.observe() .observe()
.subscribe { sharedAction -> .subscribe { sharedAction ->
when (sharedAction) { when (sharedAction) {
is HomeActivitySharedAction.OpenDrawer -> drawerLayout.openDrawer(GravityCompat.START) is HomeActivitySharedAction.OpenDrawer -> drawerLayout.openDrawer(GravityCompat.START)
is HomeActivitySharedAction.CloseDrawer -> drawerLayout.closeDrawer(GravityCompat.START) is HomeActivitySharedAction.CloseDrawer -> drawerLayout.closeDrawer(GravityCompat.START)
is HomeActivitySharedAction.OpenGroup -> { is HomeActivitySharedAction.OpenGroup -> {
drawerLayout.closeDrawer(GravityCompat.START) drawerLayout.closeDrawer(GravityCompat.START)
replaceFragment(R.id.homeDetailFragmentContainer, HomeDetailFragment::class.java, allowStateLoss = true) replaceFragment(R.id.homeDetailFragmentContainer, HomeDetailFragment::class.java, allowStateLoss = true)
} }
@ -144,9 +144,9 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
homeActivityViewModel.observeViewEvents { homeActivityViewModel.observeViewEvents {
when (it) { when (it) {
is HomeActivityViewEvents.AskPasswordToInitCrossSigning -> handleAskPasswordToInitCrossSigning(it) is HomeActivityViewEvents.AskPasswordToInitCrossSigning -> handleAskPasswordToInitCrossSigning(it)
is HomeActivityViewEvents.OnNewSession -> handleOnNewSession(it) is HomeActivityViewEvents.OnNewSession -> handleOnNewSession(it)
HomeActivityViewEvents.PromptToEnableSessionPush -> handlePromptToEnablePush() HomeActivityViewEvents.PromptToEnableSessionPush -> handlePromptToEnablePush()
is HomeActivityViewEvents.OnCrossSignedInvalidated -> handleCrossSigningInvalidated(it) is HomeActivityViewEvents.OnCrossSignedInvalidated -> handleCrossSigningInvalidated(it)
}.exhaustive }.exhaustive
} }
homeActivityViewModel.subscribe(this) { renderState(it) } homeActivityViewModel.subscribe(this) { renderState(it) }
@ -179,7 +179,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
private fun renderState(state: HomeActivityViewState) { private fun renderState(state: HomeActivityViewState) {
when (val status = state.initialSyncProgressServiceStatus) { when (val status = state.initialSyncProgressServiceStatus) {
is InitialSyncProgressService.Status.Idle -> { is InitialSyncProgressService.Status.Idle -> {
waiting_view.isVisible = false waiting_view.isVisible = false
} }
is InitialSyncProgressService.Status.Progressing -> { is InitialSyncProgressService.Status.Progressing -> {

View File

@ -121,11 +121,11 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
private suspend fun resolveUser(userId: String): User { private suspend fun resolveUser(userId: String): User {
return tryOrNull { return tryOrNull {
awaitCallback<User> { awaitCallback<User> {
session.resolveUser(userId, it) session.resolveUser(userId, it)
} }
} }
// Create raw user in case the user is not searchable // Create raw user in case the user is not searchable
?: User(userId, null, null) ?: User(userId, null, null)
} }
@ -166,19 +166,18 @@ class MatrixToBottomSheetViewModel @AssistedInject constructor(
enableEncryptionIfInvitedUsersSupportIt = adminE2EByDefault enableEncryptionIfInvitedUsersSupportIt = adminE2EByDefault
} }
val roomId = val roomId = try {
try { awaitCallback<String> { session.createRoom(roomParams, it) }
awaitCallback<String> { session.createRoom(roomParams, it) }.also { } catch (failure: Throwable) {
setState { setState {
copy(startChattingState = Success(Unit)) copy(startChattingState = Fail(Exception(stringProvider.getString(R.string.invite_users_to_room_failure))))
} }
} return@launch
} catch (failure: Throwable) { }
setState { setState {
copy(startChattingState = Fail(Exception(stringProvider.getString(R.string.invite_users_to_room_failure)))) // we can hide this button has we will navigate out
} copy(startChattingState = Uninitialized)
return@launch }
}
_viewEvents.post(MatrixToViewEvents.NavigateToRoom(roomId)) _viewEvents.post(MatrixToViewEvents.NavigateToRoom(roomId))
} }
} }