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

Stub objects for Bookmarks sync #713

Merged
merged 10 commits into from
Mar 15, 2024
Merged

Stub objects for Bookmarks sync #713

merged 10 commits into from
Mar 15, 2024

Conversation

bwaresiak
Copy link
Collaborator

@bwaresiak bwaresiak commented Mar 12, 2024

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:

  • iOS 14
  • iOS 15
  • iOS 16
  • macOS 10.15
  • macOS 11
  • macOS 12

Internal references:

Software Engineering Expectations
Technical Design Template

@bwaresiak bwaresiak marked this pull request as ready for review March 14, 2024 15:12
@bwaresiak bwaresiak requested a review from ayoy March 14, 2024 15:12
@ayoy ayoy self-assigned this Mar 15, 2024
Copy link
Contributor

@ayoy ayoy left a 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)
Copy link
Contributor

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) }
Copy link
Contributor

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? 😱

Copy link
Collaborator Author

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.

Comment on lines 95 to 99
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
Copy link
Contributor

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.

Copy link
Collaborator Author

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. 👍

Tests/BookmarksTests/BookmarkMigrationTests.swift Outdated Show resolved Hide resolved
Comment on lines +853 to +855
XCTAssertEqual(sent.count, 2)

let sentRootData = sent.first(where: { $0.payload["id"] as? String == rootFolder.uuid })
Copy link
Contributor

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.

@ayoy ayoy assigned bwaresiak and unassigned ayoy Mar 15, 2024
Copy link
Contributor

@ayoy ayoy left a 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!

@bwaresiak bwaresiak merged commit b260e97 into main Mar 15, 2024
7 checks passed
@bwaresiak bwaresiak deleted the bartek/stub-objects branch March 15, 2024 12:10
afterxleep pushed a commit that referenced this pull request Mar 15, 2024
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.
afterxleep added a commit that referenced this pull request Mar 15, 2024
* 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)
samsymons added a commit that referenced this pull request Mar 18, 2024
* main:
  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)
samsymons added a commit that referenced this pull request Mar 18, 2024
* 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants