Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] - Change email error on Account page #380

Merged
merged 7 commits into from
Nov 26, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class AccountActivity : BaseActivity<AccountViewModel.ViewModel>() {
this.viewModel.outputs.showEmailErrorIcon()
.compose(bindToLifecycle())
.compose(observeForUI())
.subscribe { ViewUtils.setGone(email_error_icon, !it) }
.subscribe { ViewUtils.setGone(email_error_icon, it) }
eoji marked this conversation as resolved.
Show resolved Hide resolved

this.viewModel.outputs.success()
.compose(bindToLifecycle())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ interface AccountViewModel {
private fun showEmailErrorImage(userPrivacy: UserPrivacyQuery.Data?): Boolean? {
return if (userPrivacy?.me()?.isCreator!! && !userPrivacy.me()?.isDeliverable!! || !userPrivacy.me()?.isEmailVerified!!) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're going to be sad but i realized the logic is simpler like this:

           return if ( !userPrivacy.me()?.isDeliverable!!) {
               return true
           } else if (userPrivacy?.me()?.isCreator!! && !userPrivacy.me()?.isEmailVerified!!) {
               return true
           } else {
               false
           }
       }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

return true
} else if (!userPrivacy.me()?.isDeliverable!! && !userPrivacy.me()?.isEmailVerified!!) {
} else if (!userPrivacy.me()?.isDeliverable!!) {
return true
} else {
false
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/activity_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@
android:id="@+id/email_error_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_horizontal_margin"
android:layout_gravity="center_vertical"
android:visibility="gone"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:layout_weight="0"
android:contentDescription="@null"
android:scaleType="centerCrop"
android:src="@drawable/ic_email_error" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ class AccountViewModelTest : KSRobolectricTestCase() {
this.showEmailErrorIcon.assertValue(true)
}

@Test
fun testShowEmailErrorIconGoneForBackerUndeliverable() {
eoji marked this conversation as resolved.
Show resolved Hide resolved
setUpEnvironment(environment().toBuilder().apolloClient(object : MockApolloClient() {
override fun userPrivacy(): Observable<UserPrivacyQuery.Data> {
return Observable.just(UserPrivacyQuery.Data(UserPrivacyQuery.Me("", "",
"", false, true, true, "MXN")))
}
}).build())

this.showEmailErrorIcon.assertValue(false)
}

@Test
fun testShowEmailErrorIconForCreatorUnverified() {
setUpEnvironment(environment().toBuilder().apolloClient(object : MockApolloClient() {
Expand Down