Commit 644d0ceb authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Add proper handling for servers that don't support the forgot password feature.

parent 406cf24f
...@@ -8,6 +8,7 @@ import chat.rocket.android.util.extensions.isEmail ...@@ -8,6 +8,7 @@ import chat.rocket.android.util.extensions.isEmail
import chat.rocket.android.util.extensions.launchUI import chat.rocket.android.util.extensions.launchUI
import chat.rocket.android.util.retryIO import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatException import chat.rocket.common.RocketChatException
import chat.rocket.common.RocketChatInvalidResponseException
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.rest.forgotPassword import chat.rocket.core.internal.rest.forgotPassword
...@@ -36,10 +37,14 @@ class ResetPasswordPresenter @Inject constructor( ...@@ -36,10 +37,14 @@ class ResetPasswordPresenter @Inject constructor(
navigator.toPreviousView() navigator.toPreviousView()
view.emailSent() view.emailSent()
} catch (exception: RocketChatException) { } catch (exception: RocketChatException) {
exception.message?.let { if (exception is RocketChatInvalidResponseException) {
view.showMessage(it) view.updateYourServerVersion()
}.ifNull { } else {
view.showGenericErrorMessage() exception.message?.let {
view.showMessage(it)
}.ifNull {
view.showGenericErrorMessage()
}
} }
} finally { } finally {
view.hideLoading() view.hideLoading()
......
...@@ -19,4 +19,9 @@ interface ResetPasswordView : LoadingView, MessageView { ...@@ -19,4 +19,9 @@ interface ResetPasswordView : LoadingView, MessageView {
* Shows a successful email sent message. * Shows a successful email sent message.
*/ */
fun emailSent() fun emailSent()
/**
* Shows a message to update the server version in order to use an app feature.
*/
fun updateYourServerVersion()
} }
\ No newline at end of file
...@@ -67,6 +67,10 @@ class ResetPasswordFragment : Fragment(), ResetPasswordView { ...@@ -67,6 +67,10 @@ class ResetPasswordFragment : Fragment(), ResetPasswordView {
showToast(R.string.msg_check_your_email_to_reset_your_password, Toast.LENGTH_LONG) showToast(R.string.msg_check_your_email_to_reset_your_password, Toast.LENGTH_LONG)
} }
override fun updateYourServerVersion() {
showMessage(R.string.msg_update_app_version_in_order_to_continue)
}
override fun showLoading() { override fun showLoading() {
ui { ui {
disableUserInput() disableUserInput()
......
...@@ -93,6 +93,8 @@ ...@@ -93,6 +93,8 @@
<string name="msg_version">Versión %1$s</string> <string name="msg_version">Versión %1$s</string>
<string name="msg_build">Build %1$d</string> <string name="msg_build">Build %1$d</string>
<string name="msg_ok">OK</string> <string name="msg_ok">OK</string>
// TODO: Add proper translation.
<string name="msg_update_app_version_in_order_to_continue">Out to date server version. Please contact the server admin to update the server version in order to continue.</string>
<string name="msg_ver_not_recommended"> <string name="msg_ver_not_recommended">
Parece que la versión de tu servidor está por debajo de la versión recomendada %1$s.\nAún puede iniciar sesión, pero puede experimentar comportamientos inesperados.</string> Parece que la versión de tu servidor está por debajo de la versión recomendada %1$s.\nAún puede iniciar sesión, pero puede experimentar comportamientos inesperados.</string>
<string name="msg_ver_not_minimum"> <string name="msg_ver_not_minimum">
......
...@@ -93,6 +93,8 @@ ...@@ -93,6 +93,8 @@
<string name="msg_version">Version %1$s</string> <string name="msg_version">Version %1$s</string>
<string name="msg_build">Build %1$d</string> <string name="msg_build">Build %1$d</string>
<string name="msg_ok">OK</string> <string name="msg_ok">OK</string>
// TODO: Add proper translation.
<string name="msg_update_app_version_in_order_to_continue">Out to date server version. Please contact the server admin to update the server version in order to continue.</string>
<string name="msg_ver_not_recommended"> <string name="msg_ver_not_recommended">
On dirait que la version de votre serveur est en dessous de la version recommandée %1$s.\nVous pouvez toujours vous connecter mais vous pouvez rencontrer des comportements inattendus.</string> On dirait que la version de votre serveur est en dessous de la version recommandée %1$s.\nVous pouvez toujours vous connecter mais vous pouvez rencontrer des comportements inattendus.</string>
<string name="msg_ver_not_minimum"> <string name="msg_ver_not_minimum">
......
...@@ -93,6 +93,8 @@ ...@@ -93,6 +93,8 @@
<string name="msg_no_messages_yet">अभी तक कोई पोस्ट नहीं</string> <string name="msg_no_messages_yet">अभी तक कोई पोस्ट नहीं</string>
<string name="msg_version">वर्शन %1$s</string> <string name="msg_version">वर्शन %1$s</string>
<string name="msg_build">बिल्ड %1$d</string> <string name="msg_build">बिल्ड %1$d</string>
// TODO: Add proper translation.
<string name="msg_update_app_version_in_order_to_continue">Out to date server version. Please contact the server admin to update the server version in order to continue.</string>
<string name="msg_ok">OK</string> <string name="msg_ok">OK</string>
<string name="msg_ver_not_recommended"> <string name="msg_ver_not_recommended">
ऐसा लगता है कि आपका सर्वर संस्करण अनुशंसित संस्करण %1$s के नीचे है।\nआप अभी भी लॉगिन कर सकते हैं लेकिन आप अप्रत्याशित व्यवहार का अनुभव कर सकते हैं ऐसा लगता है कि आपका सर्वर संस्करण अनुशंसित संस्करण %1$s के नीचे है।\nआप अभी भी लॉगिन कर सकते हैं लेकिन आप अप्रत्याशित व्यवहार का अनुभव कर सकते हैं
......
...@@ -89,6 +89,7 @@ ...@@ -89,6 +89,7 @@
<string name="msg_version">Versão %1$s</string> <string name="msg_version">Versão %1$s</string>
<string name="msg_build">Build %1$d</string> <string name="msg_build">Build %1$d</string>
<string name="msg_ok">OK</string> <string name="msg_ok">OK</string>
<string name="msg_update_app_version_in_order_to_continue">Versão do servidor desatualizada. Por favor, entre em contato com o administrador do sistema para continuar.</string>
<string name="msg_ver_not_recommended"> <string name="msg_ver_not_recommended">
Parece que a versão do seu servidor está abaixo da recomendada %1$s.\nVocê ainda assim pode logar e continuar mas podem ocorrer alguns problemas inesperados. Parece que a versão do seu servidor está abaixo da recomendada %1$s.\nVocê ainda assim pode logar e continuar mas podem ocorrer alguns problemas inesperados.
</string> </string>
......
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
<string name="msg_version">Version %1$s</string> <string name="msg_version">Version %1$s</string>
<string name="msg_build">Build %1$d</string> <string name="msg_build">Build %1$d</string>
<string name="msg_ok">OK</string> <string name="msg_ok">OK</string>
<string name="msg_update_app_version_in_order_to_continue">Out to date server version. Please contact the server admin to update the server version in order to continue.</string>
<string name="msg_ver_not_recommended"> <string name="msg_ver_not_recommended">
Looks like your server version is below the recommended version %1$s.\nYou can still login but you may experience unexpected behaviors.</string> Looks like your server version is below the recommended version %1$s.\nYou can still login but you may experience unexpected behaviors.</string>
<string name="msg_ver_not_minimum"> <string name="msg_ver_not_minimum">
......
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