Commit f00301c0 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Removes check for nullability in variables.

parent 6988897c
......@@ -93,13 +93,9 @@ class LoginPresenter @Inject constructor(private val view: LoginView,
try {
val token = client.login(usernameOrEmail, password)
if (token != null) {
multiServerRepository.save(server, TokenModel(token.userId, token.authToken))
registerPushToken()
navigator.toChatList()
} else {
view.showGenericErrorMessage()
}
} catch (exception: RocketChatException) {
when (exception) {
is RocketChatTwoFactorException -> {
......
......@@ -44,13 +44,9 @@ class TwoFAPresenter @Inject constructor(private val view: TwoFAView,
try {
// The token is saved via the client TokenProvider
val token = client.login(usernameOrEmail, password, twoFactorAuthenticationCode)
if (token != null) {
multiServerRepository.save(server, TokenModel(token.userId, token.authToken))
registerPushToken()
navigator.toChatList()
} else {
view.showGenericErrorMessage()
}
} catch (exception: RocketChatException) {
if (exception is RocketChatAuthException) {
view.alertInvalidTwoFactorAuthenticationCode()
......
......@@ -15,7 +15,6 @@ import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.chatrooms.presentation.ChatRoomsPresenter
import chat.rocket.android.chatrooms.presentation.ChatRoomsView
import chat.rocket.android.util.inflate
import chat.rocket.android.util.setVisibility
import chat.rocket.android.util.setVisible
import chat.rocket.android.widget.DividerItemDecoration
import chat.rocket.core.model.ChatRoom
......@@ -94,9 +93,7 @@ class ChatRoomsFragment : Fragment(), ChatRoomsView {
}
}
override fun showNoChatRoomsToDisplay() = text_no_data_to_display.setVisibility(true)
override fun showLoading() = view_loading.setVisibility(true)
override fun showNoChatRoomsToDisplay() = text_no_data_to_display.setVisible(true)
override fun showLoading() = view_loading.setVisible(true)
......
......@@ -10,7 +10,6 @@ import chat.rocket.common.util.ifNull
import chat.rocket.core.RocketChatClient
import chat.rocket.core.internal.rest.me
import chat.rocket.core.internal.rest.updateProfile
import timber.log.Timber
import javax.inject.Inject
class ProfilePresenter @Inject constructor (private val view: ProfileView,
......@@ -46,13 +45,8 @@ class ProfilePresenter @Inject constructor (private val view: ProfileView,
view.showLoading()
try {
val user = client.updateProfile(myselfId, email, name, username)
if (user != null) {
view.showProfileUpdateSuccessfullyMessage()
val avatarUrl = UrlHelper.getAvatarUrl(serverUrl, user.username!!)
view.showProfile(avatarUrl, user.name!!, user.username!!, user.emails?.get(0)?.address!!)
} else {
view.showGenericErrorMessage()
}
loadUserProfile()
} catch (exception: RocketChatException) {
exception.message?.let {
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