-
Notifications
You must be signed in to change notification settings - Fork 31
Attachment package refactor #311
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
Conversation
packages/powersync_attachments_stream/lib/src/local_storage.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/local_storage.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_service.dart
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.
Some more comments from a quick look.
Also, I assume supabase-todolist-new-attachments was copied from the old one? For a review it would be easier if the changes were in the same project so I can see what has changed. But that can happen in the end.
packages/powersync_attachments_stream/lib/powersync_attachments_stream.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/powersync_attachments_stream.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_queue_service.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_queue_service.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/test/local_storage_test.dart
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.
A few more comments, most of them pretty minor again :)
packages/powersync_attachments_stream/lib/src/abstractions/local_storage.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_queue_service.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/implementations/attachment_context.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/implementations/attachment_service.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/storage/io_local_storage.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_queue_service.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/storage/io_local_storage.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/sync/syncing_service.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_queue_service.dart
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.
The implementation looks good now, I have a few nits on types. I also think we should strive to not introduce classes / interfaces we don't strictly need, especially if they're publicly exported. Also more generally:
- Please run
dart format
on the package. I also recommend enabling format on save. - I think a few more tests with an actual database would be nice to have, you can take a look at the Kotlin tests for attachments for inspiration. We can test on native platforms only in the beginning, you can probably copy something like this to set up databases. But it's still a bit tricky, let me know if you need help with this. I can also push a basic scaffold for tests to this branch.
packages/powersync_attachments_stream/lib/powersync_attachments_stream.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/abstractions/attachment_context.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/abstractions/attachment_context.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/abstractions/attachment_context.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/abstractions/local_storage.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_queue_service.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_queue_service.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_queue_service.dart
Outdated
Show resolved
Hide resolved
packages/powersync_attachments_stream/lib/src/attachment_queue_service.dart
Outdated
Show resolved
Hide resolved
…handling in powersync_attachments_stream package and added unit tests
…/powersync.dart into attachment-package-refactor
…_stream package. Removed unused imports, improved error handling during file uploads and downloads, and enhanced and renamed logging for better traceability of attachment operations.
…hods, improving clarity on attachment lifecycle management, state handling, and local storage operations.
…hments package implementation to supabase-todolist demo.
… path for local storage in the powersync_attachments_stream package. Simplified the attachment watching logic. Updated README for clarity on schema and attachment states.
… classes to utilize the new interface and adjusted README for consistency.
… package. Updated attachment queue initialization to use localStorage, and enhanced README for clarity on storage handling. Added tests for edge cases and robustness in local storage operations.
…consistency. Removed outdated comment regarding attachments directory in attachment queue service documentation.
…dated photo capture widget to save attachments as byte data instead of streams, and modified related methods in the attachment queue service to accept byte data. Updated tests to reflect changes in data handling.
…comments, replacing multiple error handler parameters with a single optional error handler for sync-related errors.
…fixed various formatting
fa2f16e
to
248d748
Compare
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 left some minor comments. Overall I'm very happy with the changes here. The code is well documented and very clean :)
packages/powersync_core/lib/src/attachments/attachment_queue_service.dart
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.
This looks good to me 👍 . I'm happy to release this as is if needed, we can port the localURI changes later - potentially when we update the Kotlin SDK.
packages/powersync_core/lib/src/attachments/attachment_queue_service.dart
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.
The changes here look amazing to me.
The last thing I can think of is we might want to update the current Attachments package to maybe deprecate that and add a small reference to this new functionality.
I will do that in a separate PR once we prepare the release 👍 |
Thanks @simolus3 and @stevensJourney, I'll try to do the migration on PuffinPilot app this weekend and let you know if I see anything 🤞 I'll be able to remove my
Which is always nice 😁 |
TL;DR: Everything went fine, thanks guys! 🙌 @simolus3 @stevensJourney I migrated from my fork to this new version and everything went fine. A lot of code I was doing manually is now part of the logic of the library. So I could remove lines, which is always nice! 😎 The only "issue" I got is that I'm using Drift to manage my local database and I wasn't able to use my DAO in the Thanks again! |
This is a good point, thanks for sharing that. This is something we should be able to fix in |
This ports the new attachment APIs from the Kotlin and Swift SDKs over to Dart. For simplicity, the new APIs are added to
package:powersync_core
(with an independentpackage:powersync_core/attachments/attachments.dart
import).Unlike the old attachments helper package, the new APIs generally support the web platform as well (instead of causing compilation errors). However, one needs to explicitly provide a storage implementation, and the only builtin implementation (
IOLocalStorage
) will not work on the web. We can revisit proper web support at a later point in time.