Commit 922a9abd authored by Leonardo Aramaki's avatar Leonardo Aramaki

Fix more refactoring mistakes once again

parent 8247ced2
...@@ -12,10 +12,10 @@ import chat.rocket.core.internal.rest.me ...@@ -12,10 +12,10 @@ import chat.rocket.core.internal.rest.me
import chat.rocket.core.internal.rest.updateProfile import chat.rocket.core.internal.rest.updateProfile
import javax.inject.Inject import javax.inject.Inject
class ProfilePresenter @Inject constructor (private val view: ProfileView, class ProfilePresenter @Inject constructor(private val view: ProfileView,
private val strategy: CancelStrategy, private val strategy: CancelStrategy,
serverInteractor: GetCurrentServerInteractor, serverInteractor: GetCurrentServerInteractor,
factory: RocketChatClientFactory) { factory: RocketChatClientFactory) {
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 lateinit var myselfId: String private lateinit var myselfId: String
...@@ -28,17 +28,17 @@ class ProfilePresenter @Inject constructor (private val view: ProfileView, ...@@ -28,17 +28,17 @@ class ProfilePresenter @Inject constructor (private val view: ProfileView,
myselfId = myself.id myselfId = myself.id
val avatarUrl = UrlHelper.getAvatarUrl(serverUrl, myself.username!!) val avatarUrl = UrlHelper.getAvatarUrl(serverUrl, myself.username!!)
view.showProfile( view.showProfile(
avatarUrl, avatarUrl,
myself.name ?: "", myself.name ?: "",
myself.username ?: "", myself.username ?: "",
myself.emails?.get(0)?.address!! myself.emails?.get(0)?.address!!
) )
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
exception.message?.let { exception.message?.let {
view.showMessage(it) view.showMessage(it)
}.ifNull { }.ifNull {
view.showGenericErrorMessage() view.showGenericErrorMessage()
} }
} finally { } finally {
view.hideLoading() view.hideLoading()
} }
...@@ -49,15 +49,15 @@ class ProfilePresenter @Inject constructor (private val view: ProfileView, ...@@ -49,15 +49,15 @@ class ProfilePresenter @Inject constructor (private val view: ProfileView,
launchUI(strategy) { launchUI(strategy) {
view.showLoading() view.showLoading()
try { try {
val user = client.updateProfile(myselfId, email, name, username) val user = client.updateProfile(myselfId, email, name, null, username)
view.showProfileUpdateSuccessfullyMessage() view.showProfileUpdateSuccessfullyMessage()
loadUserProfile() loadUserProfile()
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
exception.message?.let { exception.message?.let {
view.showMessage(it) view.showMessage(it)
}.ifNull { }.ifNull {
view.showGenericErrorMessage() view.showGenericErrorMessage()
} }
} finally { } finally {
view.hideLoading() view.hideLoading()
} }
......
...@@ -54,8 +54,8 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback { ...@@ -54,8 +54,8 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
text_username.textContent = username text_username.textContent = username
text_email.textContent = email text_email.textContent = email
currentName = name currentName = username
currentUsername = username currentUsername = name
currentEmail = email currentEmail = email
profile_container.setVisible(true) profile_container.setVisible(true)
...@@ -92,7 +92,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback { ...@@ -92,7 +92,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
override fun onActionItemClicked(mode: ActionMode, menuItem: MenuItem): Boolean { override fun onActionItemClicked(mode: ActionMode, menuItem: MenuItem): Boolean {
return when (menuItem.itemId) { return when (menuItem.itemId) {
R.id.action_profile -> { R.id.action_profile -> {
presenter.updateUserProfile(text_email.textContent, text_username.textContent, text_username.textContent) presenter.updateUserProfile(text_email.textContent, text_name.textContent, text_username.textContent)
mode.finish() mode.finish()
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