-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feature(mobile): sync assets, albums & users to local database on device #1759
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
Can you add the condition triggering the sync process to the summary? |
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.
Thank you for the PR, I have a few question from the code and on noticeable bug I see is that when I sign out, the Asset
database is clear but the Album
and ExifInfo
isn't clear, so that the Sharing page show the information of album from another account.
2f37fa8
to
80ed4b5
Compare
@alextran1502 for some reason that did never occur on my device. However, I know what can cause it and fixed that by a check to open the box in any case |
4e8ce0c
to
018493d
Compare
Hi @zoodyy I got a chance to run another round of testing. I noticed that the local assets are no longer shown on the timeline. Is this the desired effect of the PR? Also, I saw a section of the |
Hey @alextran1502 thanks for testing again. That is certainly not the desired effect. |
@alextran1502 figured it out and fixed a tiny bug: only selecting "Recents" and not any individual album would result in showing/loading no device albums. |
4d64bd4
to
aa553e5
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.
Tested:
- Taking a video, it showed up the on the timeline
- Taking a photo, it showed up on the timeline
- Backups seem to work
- Gallery viewer works
Anything else you'd like me to test?
Thanks a lot for testing these! Album operations would be great as well (like add/remove assets to album, create/delete album). Also changing something on the server/web and seeing the changes reflected on the mobile. That's the main parts I can think of. |
@zoodyy Hi Fynn, the last issue I saw was not able to show local assets if I chose the upload album as Recents on iOS, which contains everything. Can you point me to the place where the local assets and remote assets are built to show on the timeline? This also applied to show all local albums if I selected the "Recents" album in commit 1dca3c8 Below is the log in If I choose another album other than the "Recents" album, only that album will show in the section of Let me know how I can help! |
@martyfuhry many thanks for testing! After some experiments, I was able to reproduce "Initial load of albums from server fails to populate the albums". The problem was: server/remote assets are loaded independently of the server/remote albums. When the albums were loaded first, they could not show any assets. I've fixed this: Now newly added albums also load their assets from the server and add them to the DB. Further, I've improved the robustness of the sync operations: They are now forced to happen sequentially. Before, they could run interleaved also leading to the error above (and even worse issues like duplicate key exceptions from the DB) |
@alextran1502 Excellent finding. That helped me a lot to build a solution that works (should work^^) on Android and iOS. With the latest commits, the photoManager lib is asked whether the |
With the two newest commits, I've fixed the problem when swiping between assets on the main timeline and jumping to wrong assets. The asset state was not sorted by createdAt - now it is. I also applied this to the album view (sorted from old to new, as before) |
This PR adds functionality to sync assets, albums & users from the server (remote) to the local (device) Isar database.
General principle: Server changes are synced to the local DB (never the other way around!) Syncing works by comparing ordered lists of items (assets, albums, users) where one list is the latest result from the server and the other list is the state in the local database.
Items staged for removal are only removed if they are no longer found/referenced elsewhere (e.g. by moving them from one local album/folder to another, or by deleting an asset from your account while the asset is still present in a album shared by someone else).
The sync operations are triggered whenever the server was previously asked to get some data, e.g. in
main.dart
getAllAsset
(whenever the app is opened) or when viewing the library/shared album page (getAllAlbums
).This does not yet enable offline usage (i.e. without network connection, you are still sent back to the login screen)
Modifies the library page to also show device-local albums (folders).
As part of the migration, it clears the JSON cache (code to be removed after a few versions).
Adds
updatedAt
to theUserResponseDto
.EDIT:
Reworked this PR; the DB syncing operations are now all consolidated in a new service
SyncService
. Further, I've rebased my work to latest main and fixed the inevitable conflicts...Fixed the reason for the endless timeline loading bug: ApiClient authToken was overwritten when setting a new endpoint
In my testing it works quite well now and is ready for another review!