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

Linked connector not restoring after iCloud restore #1013

Conversation

GhenadieVP
Copy link
Contributor

@GhenadieVP GhenadieVP commented Jan 30, 2024

Connect to the P2PLinks during the profile Restore from Backup flow.

Changes

  • Don't remove the P2PLinks from the Profile when deleting the Wallet, so those are not lost when trying to Restore from Backup.
  • When user starts the Restore from Backup flow, the Wallet pro-actively connects to the P2PLinks from the selected Profile.
  • While it was possible to connect to P2PLinks only when landing on home screen, connecting pro-actively in Restore from Backup flow, would make the experience of needing to use a Ledger device during the flow a lot better.
  • If user leaves the Restore from Backup flow, RadixConnect will remove the established connections.

Demo

Screen.Recording.2024-01-31.at.08.35.01.mov

@@ -88,6 +89,7 @@ public struct RestoreProfileFromBackupCoordinator: Sendable, FeatureReducer {
state.profileSelection = .init(snapshot: profileSnapshot, isInCloud: isInCloud)
return .run { send in
try? await clock.sleep(for: .milliseconds(300))
try await radixConnectClient.connectToP2PLinks(profileSnapshot.appPreferences.p2pLinks)
Copy link
Contributor

Choose a reason for hiding this comment

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

cant remember now, but what are we infact awaiting here? looks wrong? This mean that send(.internal(.delay..(.importMnemonicsFlow)) event is not emitted until radixConnectClient.connectToP2PLinks has finished? So what happens if you quit Chrome and redo your demo in the video? Will this RestoreProfileFromBackupCoordinator reducer wait forever until connected? Or are we using unstructured concurrency inside connectToP2PLinks ensuring it will not be 'blocking"? Otherwise, perhaps this try await inside this run must change, e.g. to a run {}.concat {} or whatever the syntax is block, or possible even Task (unstructured concurrency)?

Copy link
Contributor Author

@GhenadieVP GhenadieVP Jan 31, 2024

Choose a reason for hiding this comment

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

Will this RestoreProfileFromBackupCoordinator reducer wait forever until connected?

No, connectToP2PLinks calls the try await rtcClients.connect(password, waitsForConnectionToBeEstablished: false). if waitsForConnectionToBeEstablished == false there is no actual async code path:

	public func connect(
		_ linkPassword: ConnectionPassword,
		waitsForConnectionToBeEstablished: Bool = false
	) async throws {
		guard !clients.contains(where: { $0.key == linkPassword }) else {
			loggerGlobal.notice("Ignored connecting RTCClient with connectionPassword/id: \(linkPassword), since it is already in RTCClients.clients")
			return
		}
		let client = try makeRTCClient(linkPassword)
		if waitsForConnectionToBeEstablished {
			try await client.waitForFirstConnection()
		}
		add(client)
	}

Copy link
Contributor

@CyonAlexRDX CyonAlexRDX left a comment

Choose a reason for hiding this comment

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

LGTM

@GhenadieVP GhenadieVP merged commit 1d33233 into main Jan 31, 2024
6 checks passed
@GhenadieVP GhenadieVP deleted the fix/ABW-2386-i-os-1-0-1-alpha-8-linked-connector-not-restoring-after-i-cloud-restore branch January 31, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants