code review

This commit is contained in:
Valere 2021-05-05 11:33:12 +02:00
parent b9b3832ee3
commit ecceb0fb03
2 changed files with 10 additions and 10 deletions

View file

@ -81,14 +81,14 @@ class SpaceInviteBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetIn
dismiss()
}
val inviter = summary.inviterId?.let { session.getUser(it) }
val inviter = summary.inviterId?.let { session.getUser(it) }?.toMatrixItem()
if (inviter != null) {
views.inviterAvatarImage.isVisible = true
views.inviterText.isVisible = true
views.inviterMxid.isVisible = true
avatarRenderer.render(inviter.toMatrixItem(), views.inviterAvatarImage)
views.inviterText.text = getString(R.string.user_invites_you, inviter.getBestName())
views.inviterMxid.text = inviter.userId
avatarRenderer.render(inviter, views.inviterAvatarImage)
views.inviterText.text = getString(R.string.user_invites_you, inviter.displayName)
views.inviterMxid.text = inviter.id
} else {
views.inviterAvatarImage.isVisible = false
views.inviterText.isVisible = false
@ -142,14 +142,14 @@ class SpaceInviteBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetIn
views.spaceCard.matrixToCardSecondaryButton.button.text = getString(R.string.reject)
views.spaceCard.matrixToCardSecondaryButton.callback = object : ButtonStateView.Callback {
override fun onButtonClicked() {
doJoin()
doReject()
}
override fun onRetryClicked() {
doJoin()
doReject()
}
private fun doJoin() {
private fun doReject() {
views.spaceCard.matrixToCardSecondaryButton.render(ButtonStateView.State.Loading)
views.spaceCard.matrixToCardSecondaryButton.button.isEnabled = false
GlobalScope.launch(Dispatchers.IO) {

View file

@ -86,12 +86,11 @@ class SpacePreviewViewModel @AssistedInject constructor(
viewModelScope.launch(Dispatchers.IO) {
try {
session.spaceService().rejectInvite(initialState.idOrAlias, null)
setState { copy(inviteTermination = Uninitialized) }
} catch (failure: Throwable) {
setState { copy(inviteTermination = Uninitialized) }
Timber.e(failure, "## Space: Failed to reject invite")
_viewEvents.post(SpacePreviewViewEvents.JoinFailure(errorFormatter.toHumanReadable(failure)))
}
setState { copy(inviteTermination = Uninitialized) }
}
}
@ -115,12 +114,13 @@ class SpacePreviewViewModel @AssistedInject constructor(
_viewEvents.post(SpacePreviewViewEvents.JoinSuccess)
}
is JoinSpaceResult.Fail -> {
_viewEvents.post(SpacePreviewViewEvents.JoinFailure(joinResult.error.toString()))
_viewEvents.post(SpacePreviewViewEvents.JoinFailure(errorFormatter.toHumanReadable(joinResult.error)))
}
}
} catch (failure: Throwable) {
// should not throw
Timber.w(failure, "## Failed to join space")
_viewEvents.post(SpacePreviewViewEvents.JoinFailure(errorFormatter.toHumanReadable(failure)))
}
}
}