VPN-5932: Change where we save a new device model #8972
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This bug existed for the following situation:
The list of valid devices comes from the Guardian, and is saved in local settings (as the device list JSON). Upon launch, we check if the current device is in those devices, and if not, we ask the user to sign in again.
When we sign into the app when an account already has max devices, we retrieve the device list from Guardian twice - once upon initial launch, and a second time after we remove a device and add our current one. However, we were only saving it to settings after that first retrieval. Thus, on subsequent launch, the current device wasn't in the saved list, signing the user out.
I updated where we save the device JSON to local settings - It's now in the function where we process the new device list from Guardian. This fixes the bug, and hopefully prevents future iterations of this bug.
Note that we save the user data in the same spot, but I am not updating it as part of this bug. Arguably, we should save it to disk in the function where we process the server response, as we're changing devices here. However, there are no known issues with it currently and I'm trying to keep this patch as small as possible.
Reference
VPN-5932
Checklist