Fix Use Biometrics toggle reverting after leaving Settings#6062
Open
j0ntz wants to merge 1 commit into
Open
Conversation
The Settings biometric (Use Biometrics) toggle read its state from a cached react-query result that was never updated when the user toggled it. After leaving and re-entering Settings the scene remounted and the one-time local-state sync read the stale cached value, showing the wrong toggle state. Update the cached biometric state after persisting the change so re-entry reflects the value the user set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Requirements
If you have made any visual changes to the GUI. Make sure you have:
Description
Asana: https://app.asana.com/0/1215088146871429/1213428787796786
Fixes the Settings "Use Biometrics" toggle reverting to its previous state after the user leaves and re-enters the Settings scene.
Root cause: commit
acc2adbcmoved biometric state out of Redux into a@tanstack/react-queryquery (['biometricState', account.id]) plus a localtouchIdEnabledstate that syncs from the query only once per mount.handleUpdateTouchIdpersisted the change viaenableTouchId/disableTouchIdbut never updated the query cache, and the app-level cache has nostaleTimeand does not refetch on focus. On re-entering Settings the scene remounts, the one-time sync reads the stale cached value, and the toggle shows the old state. Reported on Android; also reproduces on iOS, since the cause is platform-agnostic.Fix: after the enable/disable persists, update the cached biometric state with
queryClient.setQueryDataso the cache reflects the value the user set. The next mount's sync then reads the correct value.Testing: added a regression test (
SettingsScene.biometric.test.tsx) that mounts the scene, toggles biometrics off, and asserts the shared query cache flips to the persisted value across a remount. It fails on the pre-fix code (cache staystrue) and passes with the fix. Fulltsc, eslint, and the jest suite pass. The toggle could not be exercised on the simulator because biometric enrollment is unavailable headlessly (nosimctlbiometry command; the Simulator Face ID enrollment menu requires GUI automation that is not reachable in this environment), so the deterministic test is the verification of the changed code path.Note
Low Risk
Small Settings-only change that updates query cache after existing keychain persistence; regression test covers the path.
Overview
Fixes Use Biometrics in Settings appearing to revert after you leave and come back.
Biometric on/off was still saved via
enableTouchId/disableTouchId, but the['biometricState', account.id]React Query cache was never updated. On remount, the scene syncs local toggle state from that cache once, so it could show the old value. After a successful persist,handleUpdateTouchIdnow callsqueryClient.setQueryDatawith the newisTouchEnabled.Adds
SettingsScene.biometric.test.tsxto assert the shared cache stays correct across unmount/remount, and a CHANGELOG entry under 4.49.0.Reviewed by Cursor Bugbot for commit 2bc3a1c. Bugbot is set up for automated code reviews on this repo. Configure here.