-
Notifications
You must be signed in to change notification settings - Fork 162
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
PageBookamrks – New Synced DB #683
base: main
Are you sure you want to change the base?
Conversation
Data/PageBookmarkPersistence/Sources/GRDBPageBookmarkPersistence.swift
Outdated
Show resolved
Hide resolved
Data/PageBookmarkPersistence/Sources/GRDBPageBookmarkPersistence.swift
Outdated
Show resolved
Hide resolved
…BookmarkPersistence package
…sistence protocol
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #683 +/- ##
==========================================
+ Coverage 40.92% 41.11% +0.18%
==========================================
Files 525 541 +16
Lines 20880 21838 +958
==========================================
+ Hits 8546 8978 +432
- Misses 12334 12860 +526 ☔ View full report in Codecov by Sentry. |
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.
Amazing work, Mohannad! I like the test cases a lot too. Just a couple of small changes and we should be good to go inshaa'Allah.
Data/SyncedPageBookmarkPersistence/Sources/SyncedPageBookmarkPersistence.swift
Outdated
Show resolved
Hide resolved
func syncedPageBookmarksPublisher() throws -> AnyPublisher<[SyncedPageBookmarkPersistenceModel], Never> | ||
func insert(bookmark: SyncedPageBookmarkPersistenceModel) async throws | ||
func removeBookmark(withRemoteID remoteID: String) async throws |
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 Sync'd bookmarks, I believe page
should be the key not the remoteID. Hence, I suggest the removeBookmark to take the page instead of remote Id.
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.
Since synched bookmarks reflect the state in the server, I guess it's safer to assume the logic of the backend. The usecase for removing a bookmark from this repository is when we receive a delete event in synchronizing with the server.
There's also another possibility where the app deletes a bookmark locally, but then this will go through the same channel when synchronizing with the server, and we'd retain the remote ID in the local DB as well, but not as a primary key.
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 think we should stick to bookmark.page
being the primary key to make it explicit that we would never have 2 bookmark entries with the same page.
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.
How about we add a unique
constraint on page
and keep the primary key for remote_id
?
This way we can keep the two ideas; signaling that page
is unique and that the design of the synced database follows the server's design.
BTW, this will be different in both the local database and the app's model.
First draft: shows a working example for a GRDB stack for page bookmarks. Tests will be similar to the CoreData variant, except that the GRDB's integration with Combine doesn't guarantee that publishers will signal every time the resources is mutated, instead it might aggregate a few mutations together.
Also, still remains to test the publisher function in
DatabaseConnection
.