-
Notifications
You must be signed in to change notification settings - Fork 37
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
Stub objects for Bookmarks sync #713
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.
All works great! I've left a few minor comments, mostly to make tests more clear. Thanks @bwaresiak!
@@ -171,11 +188,10 @@ final class BookmarksResponseHandler { | |||
var queue = queues.removeFirst() | |||
let parentUUID = parentUUIDs.removeFirst() | |||
let parent = BookmarkEntity.fetchFolder(withUUID: parentUUID, in: context) | |||
assert(parent != nil) |
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.
👍
|
||
// For non-first sync we rely fully on the server response | ||
if !shouldDeduplicateEntities { | ||
parent?.childrenArray.forEach { parent?.removeFromChildren($0) } | ||
(parent?.children?.array as? [BookmarkEntity] ?? []).forEach { parent?.removeFromChildren($0) } |
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 curious, were bookmarks pending deletion messing up the order after being undeleted? 😱
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.
If bookmark gets undeleted it should still get processed here correctly. Problem was that the stubs were not cleaned up properly as they were not removed from parent here.
let validChildrenIds = bookmark.childrenArray.compactMap(\.uuid) | ||
|
||
// Take stubs into account - we don't want to remove them. | ||
let stubIds = (bookmark.children?.array as? [BookmarkEntity] ?? []).filter({ $0.isStub }).compactMap(\.uuid) | ||
return validChildrenIds + stubIds |
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.
Why are stubs added at the end? I couldn't figure this out from the tech design.
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.
Yup, my bad, fixed and added a test. 👍
XCTAssertEqual(sent.count, 2) | ||
|
||
let sentRootData = sent.first(where: { $0.payload["id"] as? String == rootFolder.uuid }) |
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.
We could use SyncableBookmarkAdapter to make this code a bit simpler:
XCTAssertEqual(sent.map({ SyncableBookmarkAdapter(syncable: $0).uuid }), [rootFolder.uuid, "3"])
let sentRootData = sent.first(where: { SyncableBookmarkAdapter(syncable: $0).uuid == rootFolder.uuid })
But then again, SyncableBookmarkAdapter doesn't support folder changes at the moment, so the rest needs to stay as is.
Tests/SyncDataProvidersTests/Bookmarks/BookmarksProviderTests.swift
Outdated
Show resolved
Hide resolved
Tests/SyncDataProvidersTests/Bookmarks/BookmarksProviderTests.swift
Outdated
Show resolved
Hide resolved
Tests/SyncDataProvidersTests/Bookmarks/BookmarksProviderTests.swift
Outdated
Show resolved
Hide resolved
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.
LGTM! Thanks for addressing the feedback!
Required: Task/Issue URL: https://app.asana.com/0/0/1206831058661531/f iOS PR: duckduckgo/iOS#2593 macOS PR: duckduckgo/macos-browser#2418 What kind of version bump will this require?: Major Description: Provide implementation for stub objects.
* Reset Cache on Subscription Purchase & Restore * Skip sending sign out notification if account is cleared as part of failed purchase flow * URL comparison * Fix URL * Update subscription product ids * Add TF product ids * Stub objects for Bookmarks sync (#713)
* main: Update wireguard-apple to 1.1.3. (#729) Improves VPN pixel info and adds tests (#732) Reset Cache on Subscription Purchase & Restore (#719) Revert "Remove Autoconsent subfeature (#697)" (#730) Stub objects for Bookmarks sync (#713) make history entry weak to avoid retain cycle (#727) NetP x Subscription Clean-up (#709) Moves AppLaunching out of BSK as it's macOS only (#721)
Please review the release process for BrowserServicesKit here.
Required:
Task/Issue URL: https://app.asana.com/0/0/1206831058661531/f
iOS PR: duckduckgo/iOS#2593
macOS PR: duckduckgo/macos-browser#2418
What kind of version bump will this require?: Major
Description:
Provide implementation for stub objects.
Steps to test this PR:
On platforms, navigate to debug menu and populate stubs in the DB. UX should not be affected by stubs.
Validate tests if they cover all scenarios.
Smoke tests sync.
OS Testing:
Internal references:
Software Engineering Expectations
Technical Design Template