fix(contacts): resolve seed-login race conditions in contacts and payment linking#831
Merged
Merged
Conversation
Three issues caused the contacts permission gate to re-appear in the send flow after granting permission during seed restore onboarding: 1. performSync() empty-contacts early return did not set hasEverSynced, so the send flow gate condition still evaluated true. 2. The onboarding ContactPermissionStepContent only granted the OS permission and proceeded -- it never triggered contactCoordinator.sync(). The send flow then saw no synced contacts and showed the gate again. 3. The Flipcash contacts discovery modal used an imperative currentStep check inside a filter on contactCoordinator.state, which only evaluated when contact state changed. If the state was already settled from the onboarding sync, the modal never fired. Replaced with combine() so changes to either source trigger re-evaluation. Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
Interactive logins (seed input, deep link, credential picker) set AuthState.Ready too early because hasCompletedOnboarding() defaults to true for backward compat on new devices. This triggered onAppInForeground -- and linkForPaymentIfNeeded -- while permission screens were still up. Fix: for non-soft logins, always force completedOnboarding to false so auth routes through Onboarding(PostAccessKey). The permissions flow sets Ready on completion at the right time. Soft logins (app restart) still trust the persisted flag. Additionally, guard linkForPaymentIfNeeded with a Mutex so overlapping calls from the auth-state observer and ON_RESUME lifecycle cannot race into duplicate RPCs. Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
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.
Summary
performSync()empty-contacts path didn't sethasEverSynced, the onboarding permission screen never triggered a sync, and the Flipcash contacts discovery modal used an imperativecurrentStepcheck that missed already-settled state.linkForPaymentfiring prematurely during onboarding:hasCompletedOnboarding()defaults totrueon new devices (backward compat), causingAuthManager.loginto setReadyimmediately for interactive logins — before permission screens finished. This triggeredonAppInForegroundside effects too early. Additionally, overlappingonAppInForegroundcalls (auth-state observer +ON_RESUMElifecycle) raced into duplicatelinkForPaymentRPCs.