-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix sync connect flow #1195
Fix sync connect flow #1195
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great! 👏 Left a suggestion about Combine code, but I’m not strong on it.
@@ -269,7 +283,21 @@ extension SyncPreferences: ManagementDialogModelDelegate { | |||
presentDialog(for: .deviceSynced) | |||
} else if let connectKey = syncCode.connect { | |||
// Unclear what the UX is supposed to be here given everything is happening on the other device |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking - has there been any progress on how the UX should be? Perhaps we can remove this comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove this. Given this version reacts when a new device is added that might be good enough for now.
@MainActor | ||
func presentShowOrEnterCodeDialog() { | ||
Task { @MainActor in | ||
let devicesAtStart = self.devices | ||
showOrEnterCodeDevicesCancellable = self.$devices.sink { [weak self] value in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this should be equivalent:
showOrEnterCodeDevicesCancellable = self.$devices
.removeDuplicates()
.prefix(1)
.sink { [weak self] _ in
self?.managementDialogModel.endFlow()
}
Using prefix(1)
makes the subscription to complete after first emitted value, and as such it doesn’t have to be cancelled manually. Not sure if this version is more readable to people other than me, so if in doubt, keep your version :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite. The code checks that the array is different and then calls end flow if it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking that the array is different is also there - handled by removeDuplicates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh nice, i missed that! thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ended up having to drop the first event and then firing objectWillChange
on the model, but it's much cleaner
* upstream_develop: sync device connected names (#1205) Autofill/subdomain matching (#1122) add-windows-browser-download-link-privacy-config (#1198) Update metadata Fix creating DMG from release workflow (#1200) Unit tests to cover sensitive areas of Burner Window (#1169) [Hackdays] Share via QR Code (#1177) Fix sync connect flow (#1195) Update to BSK adding new remote message image (#1194) Set version to 1.39.0 Update embedded files Update old Dax asset (#1193) WebKit find in page (#1188) modify manage bookmarks button (#1175) sync update device model / poll for devices (#1191)
Task/Issue URL: https://app.asana.com/0/0/1204398270301335/f
Tech Design URL:
CC:
Description:
Fixes the connect flow. No BSK changes.
Steps to test this PR:
Internal references:
Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation