Unverified Commit c9147d73 authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge pull request #1863 from RocketChat/fix/display-username

[FIX] Username not being displayed.
parents c0f75bad fcfb22ea
...@@ -62,10 +62,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, ...@@ -62,10 +62,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
refreshPushToken() refreshPushToken()
chatRoomId = intent.getStringExtra(INTENT_CHAT_ROOM_ID) chatRoomId = intent.getStringExtra(INTENT_CHAT_ROOM_ID)
println("ChatRoomId: $chatRoomId")
presenter.clearNotificationsForChatroom(chatRoomId) presenter.clearNotificationsForChatroom(chatRoomId)
presenter.connect() presenter.connect()
......
...@@ -29,7 +29,6 @@ import chat.rocket.core.internal.rest.setAvatar ...@@ -29,7 +29,6 @@ import chat.rocket.core.internal.rest.setAvatar
import chat.rocket.core.internal.rest.updateProfile import chat.rocket.core.internal.rest.updateProfile
import kotlinx.coroutines.experimental.DefaultDispatcher import kotlinx.coroutines.experimental.DefaultDispatcher
import kotlinx.coroutines.experimental.withContext import kotlinx.coroutines.experimental.withContext
import java.lang.Exception
import java.util.* import java.util.*
import javax.inject.Inject import javax.inject.Inject
...@@ -58,20 +57,17 @@ class ProfilePresenter @Inject constructor( ...@@ -58,20 +57,17 @@ class ProfilePresenter @Inject constructor(
) { ) {
private val serverUrl = serverInteractor.get()!! private val serverUrl = serverInteractor.get()!!
private val client: RocketChatClient = factory.create(serverUrl) private val client: RocketChatClient = factory.create(serverUrl)
private val myselfId = userHelper.user()?.id ?: "" private val user = userHelper.user()
private var myselfName = userHelper.user()?.name ?: ""
private var myselfUsername = userHelper.username() ?: ""
private var myselfEmailAddress = userHelper.user()?.emails?.getOrNull(0)?.address ?: ""
fun loadUserProfile() { fun loadUserProfile() {
launchUI(strategy) { launchUI(strategy) {
view.showLoading() view.showLoading()
try { try {
view.showProfile( view.showProfile(
serverUrl.avatarUrl(myselfUsername), serverUrl.avatarUrl(user?.username ?: ""),
myselfName, user?.name ?: "",
myselfUsername, user?.username ?: "",
myselfEmailAddress user?.emails?.getOrNull(0)?.address ?: ""
) )
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
view.showMessage(exception) view.showMessage(exception)
...@@ -85,14 +81,16 @@ class ProfilePresenter @Inject constructor( ...@@ -85,14 +81,16 @@ class ProfilePresenter @Inject constructor(
launchUI(strategy) { launchUI(strategy) {
view.showLoading() view.showLoading()
try { try {
retryIO { client.updateProfile(myselfId, email, name, username) } user?.id?.let { id ->
retryIO { client.updateProfile(id, email, name, username) }
myselfEmailAddress = email
myselfName = name
myselfUsername = username
view.showProfileUpdateSuccessfullyMessage() view.showProfileUpdateSuccessfullyMessage()
loadUserProfile() view.showProfile(
serverUrl.avatarUrl(user.username ?: ""),
name,
username,
email
)
}
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
exception.message?.let { exception.message?.let {
view.showMessage(it) view.showMessage(it)
...@@ -117,7 +115,7 @@ class ProfilePresenter @Inject constructor( ...@@ -117,7 +115,7 @@ class ProfilePresenter @Inject constructor(
uriInteractor.getInputStream(uri) uriInteractor.getInputStream(uri)
} }
} }
view.reloadUserAvatar(serverUrl.avatarUrl(myselfUsername)) user?.username?.let { view.reloadUserAvatar(it) }
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
exception.message?.let { exception.message?.let {
view.showMessage(it) view.showMessage(it)
...@@ -144,7 +142,8 @@ class ProfilePresenter @Inject constructor( ...@@ -144,7 +142,8 @@ class ProfilePresenter @Inject constructor(
byteArray?.inputStream() byteArray?.inputStream()
} }
} }
view.reloadUserAvatar(serverUrl.avatarUrl(myselfUsername))
user?.username?.let { view.reloadUserAvatar(it) }
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
exception.message?.let { exception.message?.let {
view.showMessage(it) view.showMessage(it)
...@@ -161,8 +160,10 @@ class ProfilePresenter @Inject constructor( ...@@ -161,8 +160,10 @@ class ProfilePresenter @Inject constructor(
launchUI(strategy) { launchUI(strategy) {
view.showLoading() view.showLoading()
try { try {
retryIO { client.resetAvatar(myselfId) } user?.id?.let { id ->
view.reloadUserAvatar(serverUrl.avatarUrl(myselfUsername)) retryIO { client.resetAvatar(id) }
}
user?.username?.let { view.reloadUserAvatar(it) }
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
exception.message?.let { exception.message?.let {
view.showMessage(it) view.showMessage(it)
......
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