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

Update Settings: Update VPN settings item #5394

Merged
merged 20 commits into from
Dec 19, 2024

Conversation

mikescamell
Copy link
Contributor

@mikescamell mikescamell commented Dec 16, 2024

Task/Issue URL: https://app.asana.com/0/0/1208966262488271/f

Description

Updates the VPN settings item to match new designs. As the new designs require us to know more about the subscription state we need to expose more Subscription Statuses so we can reflect that in the settings screen like the "Waiting" state that is equivalent to our new "Activating" state.

The biggest thing to note is that now it's not like it used to be where we had just 2 states, locked and unlocked, we now more readily show the user the VPN item and what it's subscription state is.

I'm still waiting on answers regarding the onboarded state

And connecting state but I can always circle back later and address these as necessary.

Designs

Steps to test this PR

Prerequisite: Enable newSettings feature toggle

Prerequisite: Apply the patch in the Asana task

Note: Only the VPN item and possibly the Settings item will be seen, depending on the different states. PIR, ITR are not included as part of this PR and so are not visible.

VPN Subscribed and Off

  • Open New Settings
  • Verify VPN item is visible with colored icon and status is off
  • Click VPN item
  • VPN settings screen should open

VPN Subscribed and On

  • In NetworkProtectionStateImpl change ln 98 to return flowOf(CONNECTED)
  • Open New Settings
  • Verify VPN item is visible with colored icon and status is on
  • Click VPN item
  • VPN settings screen should open

Unsubscribed

  • In SubscriptionManager change ln 442 to return SubscriptionStatus.UNKNOWN
  • Open New Settings
  • Verify VPN item is not visible

VPN Expired

  • In SubscriptionManager change ln 442 to return SubscriptionStatus.EXPIRED
  • Open New Settings
  • Verify VPN item is visible with grey icon and is not clickable, and status is off
  • Click VPN item
  • Nothing should happen

PPro Activating

  • In SubscriptionManager change ln 442 to return SubscriptionStatus.WAITING
  • Open New Settings
  • Verify VPN item is visible with grey icon and status is off
  • Click VPN item
  • Nothing should happen

No Entitlement

  • In SubscriptionManager change ln 442 to return SubscriptionStatus.AUTO_RENEWABLE
  • In RealSubscriptions change ln 77 to return flowOf(listOf())
  • Open New Settings
  • Verify VPN item is not visible

Legacy Support

  • Turn off newSettings
  • Verify old VPN settings works by repeating steps above

UI changes

Before After
old_vpn_active vpn_subscribed_on
old_vpn_disconnected vpn_subscribed_off
old_vpn_waiting vpn_activating
old_vpn_ineligible new_vpn_ineligible

Copy link
Contributor Author

mikescamell commented Dec 16, 2024

@mikescamell mikescamell force-pushed the feature/mike/update-settings/update-ppro-vpn-item branch from f436476 to d306ac3 Compare December 16, 2024 15:08
@mikescamell mikescamell force-pushed the feature/mike/update-settings/update-ppro-vpn-item branch 3 times, most recently from 72f177a to 76b9911 Compare December 17, 2024 09:30
@mikescamell mikescamell marked this pull request as ready for review December 17, 2024 13:03
@malmstein malmstein self-assigned this Dec 17, 2024
@mikescamell mikescamell force-pushed the feature/mike/update-settings/update-ppro-vpn-item branch from 76b9911 to 49dea28 Compare December 18, 2024 09:50
Copy link
Contributor

@malmstein malmstein left a comment

Choose a reason for hiding this comment

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

Works as expected, check with @aitorvs and @karlenDimla for changes related to NetP API.

Copy link
Contributor

@malmstein malmstein left a comment

Choose a reason for hiding this comment

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

As discussed offline, the only thing I’d look into changing is to move all the UI States into the impl module because they don’t need to be exposed.

@mikescamell
Copy link
Contributor Author

mikescamell commented Dec 18, 2024

Works as expected, check with @aitorvs and @karlenDimla for changes related to NetP API.

Please hold off checking until I've made some changes, I think we can move the new NetworkProtectionAccessState API to the impl module as no other module is using it.

@aitorvs
Copy link
Collaborator

aitorvs commented Dec 18, 2024

Works as expected, check with @aitorvs and @karlenDimla for changes related to NetP API.

Please hold off checking until I've made some changes, I think we can move the new NetworkProtectionAccessState API to the impl module as no other module is using it.

I will review the changes.
We should not need to change the VPN public API to revamp settings.
And I've seen some odd changes, for instance we're moving subscription state to the netp public API, that should not be.

Comment on lines +52 to +54
if (!status.isActive()) {
// if entitlement check succeeded and not an active subscription then reset state
handleRevokedVPNState()
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this logic be here?
If I understand correctly, a user can have an inactive subscription but continue using the VPN as long as they don't open settings? That seems odd/wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm taking the logic that already exists in NetworkProtectionAccessStateImpl and adding it here.

   override suspend fun getStateFlow(): Flow<NetPAccessState> = withContext(dispatcherProvider.io()) {
        netpSubscriptionManager.vpnStatus().map { status ->
            if (!status.isActive()) {
                // if entitlement check succeeded and no entitlement, reset state and hide access.
                handleRevokedVPNState()
                Locked
            } else {
                UnLocked
            }
        }
    }

This is only ever called by the current NetP Settings item: ProSettingNetPViewModel (LegacyProSettingNetPViewModel in this PR)

Once the new Settings is rolled out, NetworkProtectionAccessStateImpl.getStateFlow will never be called, so I wanted to ensure the behaviour stays the same when that eventually happens.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed on Zoom, this is existing behaviour in the Legacy ProSettingNetPViewModel and therefore I'm going to leave it as is so as not to affect existing behaviour.

@mikescamell mikescamell force-pushed the feature/mike/update-settings/update-ppro-vpn-item branch 2 times, most recently from b9956a7 to 8bde9db Compare December 18, 2024 17:31
copy paste of legacy
We'll need more states to represent our new VPN statuses as we'll see in upcoming commits.
The VPN status states have changed for the new settings as we need to know more about the subscription status of the VPN to correctly render the new states, therefore we need to know if we're in a waiting state so we can in future render an "Activating" state

We
Locked and Unlocked are no longer sufficient for us to render the correct states.

We add a new NetPVisibilityState which tells us if we should show the VPN item to the user, and if we do, what it's subscription state is.

I'm not entirely sure about nesting the subscription status, or having this as a property of Visible state, I'm open to suggestions
With all the new information and states we can now render the VPN item correctly and kill off some of the legacy code we copied over
Seeing as we will aim to get rid of the netpAccessState.getLegacyState() function we need to change to use the new netpAccessState.getState() in the RealVpnTileStateProvider

Practically the same, just rejigged the order to make more sense
This is an internal only class used to determine the state for the settings item as we need to know more information about the user's subscription to determine how to show the new VPN item
After talking to Aitor about onboarding we decided even though no one could give me an answer yesterday RE if we still want onboarding checks we should probably add this back in so we're consistent with previous behaviour
@mikescamell mikescamell force-pushed the feature/mike/update-settings/update-ppro-vpn-item branch from 8bde9db to 81c774d Compare December 18, 2024 18:47
@mikescamell mikescamell force-pushed the feature/mike/update-settings/update-ppro-vpn-item branch from 81c774d to da4e853 Compare December 18, 2024 18:50
@mikescamell mikescamell merged commit b7af5ce into develop Dec 19, 2024
6 checks passed
@mikescamell mikescamell deleted the feature/mike/update-settings/update-ppro-vpn-item branch December 19, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants