Commit 37c2f375 authored by Lucio Maciel's avatar Lucio Maciel

Fix missing email crash on ProfileFragment

parent 7b7997d5
...@@ -30,11 +30,12 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView, ...@@ -30,11 +30,12 @@ class ProfilePresenter @Inject constructor(private val view: ProfileView,
val myself = retryIO("me") { client.me() } val myself = retryIO("me") { client.me() }
myselfId = myself.id!! myselfId = myself.id!!
val avatarUrl = serverUrl.avatarUrl(myself.username!!) val avatarUrl = serverUrl.avatarUrl(myself.username!!)
val email = myself.emails?.getOrNull(0)?.address
view.showProfile( view.showProfile(
avatarUrl, avatarUrl,
myself.name ?: "", myself.name ?: "",
myself.username ?: "", myself.username ?: "",
myself.emails?.get(0)?.address!! email
) )
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
view.showMessage(exception) view.showMessage(exception)
......
...@@ -2,7 +2,6 @@ package chat.rocket.android.profile.presentation ...@@ -2,7 +2,6 @@ package chat.rocket.android.profile.presentation
import chat.rocket.android.core.behaviours.LoadingView import chat.rocket.android.core.behaviours.LoadingView
import chat.rocket.android.core.behaviours.MessageView import chat.rocket.android.core.behaviours.MessageView
import chat.rocket.core.model.Myself
interface ProfileView : LoadingView, MessageView { interface ProfileView : LoadingView, MessageView {
...@@ -14,7 +13,7 @@ interface ProfileView : LoadingView, MessageView { ...@@ -14,7 +13,7 @@ interface ProfileView : LoadingView, MessageView {
* @param username The user username. * @param username The user username.
* @param email The user email. * @param email The user email.
*/ */
fun showProfile(avatarUrl: String, name: String, username: String, email: String) fun showProfile(avatarUrl: String, name: String, username: String, email: String?)
/** /**
* Shows a profile update successfully message * Shows a profile update successfully message
......
...@@ -55,18 +55,18 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback { ...@@ -55,18 +55,18 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
super.onDestroyView() super.onDestroyView()
} }
override fun showProfile(avatarUrl: String, name: String, username: String, email: String) { override fun showProfile(avatarUrl: String, name: String, username: String, email: String?) {
ui { ui {
image_avatar.setImageURI(avatarUrl) image_avatar.setImageURI(avatarUrl)
text_name.textContent = name text_name.textContent = name
text_username.textContent = username text_username.textContent = username
text_email.textContent = email text_email.textContent = email ?: ""
text_avatar_url.textContent = "" text_avatar_url.textContent = ""
currentName = name currentName = name
currentUsername = username currentUsername = username
currentEmail = email currentEmail = email ?: ""
currentAvatar = avatarUrl currentAvatar = avatarUrl
profile_container.setVisible(true) profile_container.setVisible(true)
......
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