Fix wrong index in form host value (#507)

This commit is contained in:
Rafał Borcz 2019-09-16 23:27:58 +02:00 committed by Mikołaj Pich
parent 3ee98e2bd0
commit 6089df9462
3 changed files with 9 additions and 12 deletions

View File

@ -38,7 +38,7 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
override val formPassValue get() = loginFormPass.text.toString()
override val formHostValue get() = hostValues[(hostKeys.indexOf(loginFormHost.text.toString()))]
override val formHostValue get() = hostValues.getOrNull(hostKeys.indexOf(loginFormHost.text.toString()))
private lateinit var hostKeys: Array<String>
@ -146,13 +146,8 @@ class LoginFormFragment : BaseFragment(), LoginFormView {
loginFormPrivacyLink.visibility = VISIBLE
}
override fun notifyParentAccountLogged(students: List<Student>) {
(activity as? LoginActivity)?.onFormFragmentAccountLogged(students,
Triple(
loginFormName.text.toString(),
loginFormPass.text.toString(),
formHostValue
))
override fun notifyParentAccountLogged(students: List<Student>, loginData: Triple<String, String, String>) {
(activity as? LoginActivity)?.onFormFragmentAccountLogged(students, loginData)
}
override fun openPrivacyPolicyPage() {

View File

@ -40,7 +40,9 @@ class LoginFormPresenter @Inject constructor(
view?.apply {
clearPassError()
clearNameError()
if (formHostValue.contains("fakelog")) setCredentials("jan@fakelog.cf", "jan123")
if (formHostValue?.contains("fakelog") == true) {
setCredentials("jan@fakelog.cf", "jan123")
}
}
}
@ -79,7 +81,7 @@ class LoginFormPresenter @Inject constructor(
.subscribe({
Timber.i("Login result: Success")
analytics.logEvent("registration_form", "success" to true, "students" to it.size, "endpoint" to endpoint, "error" to "No error")
view?.notifyParentAccountLogged(it)
view?.notifyParentAccountLogged(it, Triple(email, password, endpoint))
}, {
Timber.i("Login result: An exception occurred")
analytics.logEvent("registration_form", "success" to false, "students" to -1, "endpoint" to endpoint, "error" to it.message.ifNullOrBlank { "No message" })

View File

@ -11,7 +11,7 @@ interface LoginFormView : BaseView {
val formPassValue: String
val formHostValue: String
val formHostValue: String?
fun setCredentials(name: String, pass: String)
@ -39,7 +39,7 @@ interface LoginFormView : BaseView {
fun showPrivacyPolicy()
fun notifyParentAccountLogged(students: List<Student>)
fun notifyParentAccountLogged(students: List<Student>, loginData: Triple<String, String, String>)
fun openPrivacyPolicyPage()
}