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

[Wallet] Prevent exiting force update screen #5430

Merged
merged 14 commits into from
Oct 21, 2020
Merged

[Wallet] Prevent exiting force update screen #5430

merged 14 commits into from
Oct 21, 2020

Conversation

gnardini
Copy link
Contributor

@gnardini gnardini commented Oct 19, 2020

Description

The Update screen could be dismissed before this PR. It shouldn't be dismissable, the intention is to force the update.

I had to add the min required version in Redux to force the screen when backgrounding and reopening the app since if the app was reloaded the screen could still be skipped. This happened specially on Android.

Tested

Locally changing the app version on both platforms.

Related issues

Copy link
Contributor

@jeanregisser jeanregisser left a comment

Choose a reason for hiding this comment

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

Thanks!! 🥇

Just to be sure, this also prevents dismissing using the Android back button, or "swipe back" on iOS, right?

@gnardini
Copy link
Contributor Author

@jeanregisser I'm sorry, I updated the PR just before your comment :( You might want to take another look.

It does prevent swiping back and pressing the back button, yes!

Comment on lines 122 to 129
let updateRequired = false
if (minRequiredVersion) {
const version = DeviceInfo.getVersion()
updateRequired = isVersionBelowMinimum(version, minRequiredVersion)
if (!updateRequired) {
dispatch(setRequiredVersion(null))
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't dispatch during render.
This logic should live in a saga.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is run only once. Which saga do you think this belongs on? I understand where you're coming from, but this seemed like the most intuitive way to solve this and I don't see a big risk dispatching here.

@@ -26,6 +26,7 @@ export enum Actions {
UNLOCK = 'APP/UNLOCK',
SET_SESSION_ID = 'SET_SESSION_ID',
OPEN_URL = 'APP/OPEN_URL',
SET_REQUIRED_VERSION = 'APP/SET_REQUIRED_VERSION',
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to avoid introducing new setters and try to gradually migrate to events.
How about we use MIN_APP_VERSION_DETERMINED instead?

Comment on lines 58 to 68
const updateRequired = React.useMemo(() => {
if (!minRequiredVersion) {
return false
}
const version = DeviceInfo.getVersion()
const versionBelowMinimum = isVersionBelowMinimum(version, minRequiredVersion)
if (!versionBelowMinimum) {
dispatch(minAppVersionDetermined(null))
}
return versionBelowMinimum
}, [minRequiredVersion])
Copy link
Contributor

Choose a reason for hiding this comment

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

Still feels wrong, I don't understand why we need to call dispatch here.

This should be in a selector I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I just wanted to avoid doing this device check every time, if we already know the user updated the app I feel it would be better to have the minRequiredVersion as null but I guess we can just not dispatch anything and check against the latest minRequiredVersion found every time.

Is something like this what you had in mind?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I think so! Happy to chat about this tomorrow, I might have missed something here.

Copy link
Contributor

@tarikbellamine tarikbellamine left a comment

Choose a reason for hiding this comment

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

Question - how is the swipe and hardware back button being disabled?

My understanding is that swipes need to be disabled like this: https://github.com/celo-org/celo-monorepo/blob/master/packages/mobile/src/navigator/Headers.tsx#L24

and hardware back button needs to be overwritten with an event listener like this: https://github.com/celo-org/celo-monorepo/blob/master/packages/mobile/src/identity/PhoneNumberLookupQuotaScreen.tsx#L42

@gnardini
Copy link
Contributor Author

Question - how is the swipe and hardware back button being disabled?

They were disabled with two mechanisms, depending on the situation:

  • The first one is when going through the Firebase saga, which happens when the version mismatch is found. I changed the navigate by a replace, so the stack contains only the update screen. Swiping doesn't work and if the user presses the back button on android the app is just closed since it's the only screen in the stack.

  • If the app is reloaded somehow (can happen if the app is backgrounded for a period of time or on old phones) then the redux state is used and the same thing that is used for the pincode on open is used. Basically the update screen is drawn on top of the home screen, so the user can't interact with anything and just sees the update screen. Swiping or pressing back doesn't work because it's not a new screen on the stack, it's just drawn on top of it.

The two cases you pointed out are for when there are other screens in the stack, but it's not the case here.

@gnardini
Copy link
Contributor Author

Changed the implementation so that the minVersion is read in real time from Firebase,

Copy link
Contributor

@jeanregisser jeanregisser left a comment

Choose a reason for hiding this comment

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

Great! :shipit: 👍

@gnardini gnardini added the automerge Have PR merge automatically when checks pass label Oct 21, 2020
@mergify mergify bot merged commit 41af5e8 into master Oct 21, 2020
@mergify mergify bot deleted the force-update branch October 21, 2020 14:32
gnardini added a commit that referenced this pull request Oct 21, 2020
### Description

The Update screen could be dismissed before this PR. It shouldn't be dismissable, the intention is to force the update.

I had to add the min required version in Redux to force the screen when backgrounding and reopening the app since if the app was reloaded the screen could still be skipped. This happened specially on Android.

### Tested

Locally changing the app version on both platforms.

### Related issues

- Fixes #5429
@Lss-Ankit
Copy link

Hey @gnardini i have verified tried to verify this task with taking play store v1.2 but not getting Force update screen.
can you please let me know how I can check this scenarios with v1.3
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass wallet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix "Force Update" mechanism in Valora
4 participants