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