Commit 38fd7a5e authored by Lucio Maciel's avatar Lucio Maciel

Don't crash on invalid fields for /me

We need to see how to better handle it.
parent 9882f0b4
...@@ -28,8 +28,13 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView, ...@@ -28,8 +28,13 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView,
view.showLoading() view.showLoading()
try { try {
val myself = retryIO("me") { client.me() } val myself = retryIO("me") { client.me() }
myselfId = myself.id!! val id = myself.id
val avatarUrl = serverUrl.avatarUrl(myself.username!!) val username = myself.username
if (id == null || username == null) {
view.showGenericErrorMessage()
} else {
myselfId = id
val avatarUrl = serverUrl.avatarUrl(username)
val email = myself.emails?.getOrNull(0)?.address val email = myself.emails?.getOrNull(0)?.address
view.showProfile( view.showProfile(
avatarUrl, avatarUrl,
...@@ -37,6 +42,7 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView, ...@@ -37,6 +42,7 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView,
myself.username ?: "", myself.username ?: "",
email email
) )
}
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
view.showMessage(exception) view.showMessage(exception)
} finally { } finally {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment