Commit 4e5b2997 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Fix user status always being displayed as offline.

parent 7c524d97
...@@ -24,6 +24,7 @@ import chat.rocket.common.model.userStatusOf ...@@ -24,6 +24,7 @@ import chat.rocket.common.model.userStatusOf
import chat.rocket.common.util.ifNull import chat.rocket.common.util.ifNull
import chat.rocket.core.RocketChatClient import chat.rocket.core.RocketChatClient
import chat.rocket.core.internal.realtime.setDefaultStatus import chat.rocket.core.internal.realtime.setDefaultStatus
import chat.rocket.core.internal.rest.me
import chat.rocket.core.internal.rest.resetAvatar import chat.rocket.core.internal.rest.resetAvatar
import chat.rocket.core.internal.rest.setAvatar import chat.rocket.core.internal.rest.setAvatar
import chat.rocket.core.internal.rest.updateProfile import chat.rocket.core.internal.rest.updateProfile
...@@ -61,12 +62,16 @@ class ProfilePresenter @Inject constructor( ...@@ -61,12 +62,16 @@ class ProfilePresenter @Inject constructor(
launchUI(strategy) { launchUI(strategy) {
view.showLoading() view.showLoading()
try { try {
val me = retryIO(description = "serverInfo", times = 5) {
client.me()
}
view.showProfile( view.showProfile(
user?.status.toString(), me.status.toString(),
serverUrl.avatarUrl(user?.username ?: ""), serverUrl.avatarUrl(me.username ?: ""),
user?.name ?: "", me.name ?: "",
user?.username ?: "", me.username ?: "",
user?.emails?.getOrNull(0)?.address ?: "" me.emails?.getOrNull(0)?.address ?: ""
) )
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
view.showMessage(exception) view.showMessage(exception)
......
...@@ -20,6 +20,7 @@ import chat.rocket.android.util.extensions.avatarUrl ...@@ -20,6 +20,7 @@ import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.retryIO import chat.rocket.android.util.retryIO
import chat.rocket.common.util.ifNull import chat.rocket.common.util.ifNull
import chat.rocket.core.internal.rest.deleteOwnAccount import chat.rocket.core.internal.rest.deleteOwnAccount
import chat.rocket.core.internal.rest.me
import chat.rocket.core.internal.rest.serverInfo import chat.rocket.core.internal.rest.serverInfo
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
...@@ -59,11 +60,16 @@ class SettingsPresenter @Inject constructor( ...@@ -59,11 +60,16 @@ class SettingsPresenter @Inject constructor(
val serverInfo = retryIO(description = "serverInfo", times = 5) { val serverInfo = retryIO(description = "serverInfo", times = 5) {
rocketChatClientFactory.get(currentServer).serverInfo() rocketChatClientFactory.get(currentServer).serverInfo()
} }
val me = retryIO(description = "serverInfo", times = 5) {
rocketChatClientFactory.get(currentServer).me()
}
userHelper.user()?.let { user -> userHelper.user()?.let { user ->
view.setupSettingsView( view.setupSettingsView(
currentServer.avatarUrl(user.username ?: ""), currentServer.avatarUrl(me.username ?: ""),
userHelper.displayName(user) ?: user.username ?: "", userHelper.displayName(user) ?: me.username ?: "",
user.status.toString(), me.status.toString(),
permissions.isAdministrationEnabled(), permissions.isAdministrationEnabled(),
analyticsTrackingInteractor.get(), analyticsTrackingInteractor.get(),
true, 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