fix(mobile): avoid duplicate assets in album view#28152
Open
stfn42 wants to merge 1 commit intoimmich-app:mainfrom
Open
fix(mobile): avoid duplicate assets in album view#28152stfn42 wants to merge 1 commit intoimmich-app:mainfrom
stfn42 wants to merge 1 commit intoimmich-app:mainfrom
Conversation
Member
|
@stfn42 Hey, Thanks a lot for the fix. This re-creates a de-duplicated view for joining for every method call, which happens quite often when scrolling the timeline. Rather, it might be best to use corelated subqueries like the main timeline. Can you update the fix to use them instead? |
320c37f to
4c78806
Compare
Author
|
@shenlong-tanwen Yeah, that's good feedback, thanks. Updated version uses same approach as merged_asset.drift. PTAL :). |
4c78806 to
cc67650
Compare
Author
|
Fixed dart formatting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
As outlined in the descriptions on issue #23273, when the same photo is added to multiple albums on Android devices, this results in multiple localAssetEntity rows with the same checksum. The previous LEFT OUTER JOIN on the checksum caused fanning out into multiple duplicate rows, which caused photos to be shown multiple times in the album view (e.g. Shared Albums). Because only the asset query seems to fan out, it also causes offsets to drift, so assets will be rendered with the wrong date.
The most likely root cause for this issue to appear in the first place is probably people receiving photos via various apps and saving them to Camera Roll and defaulting to synching all albums. Ultimately, how many copies of identical photos people want to maintain is a personal choice and the offset drift is still unpleasant.
Fixed by joining against a pre-deduplicated subquery (GROUP BY checksum) instead of the raw table, so each remote asset should only match one local row. Subquery would probably also work, but would be slower on larger albums in particular. Resolves described issue successfully on a Pixel 9 Pro.
Fixes #23273
How Has This Been Tested?
To reproduce the underlying issue, an Android device needs an identical photo to exist in multiple device albums (e.g. Camera and WhatsApp Images).
flutter test- All 668 tests pass (with 1 skipped)Checklist:
[ ] All code inN/A, change effects /mobile onlysrc/services/uses repositories implementations for database calls, filesystem operations, etc.[ ] All code inN/A, change effects /mobile onlysrc/repositories/is pretty basic/simple and does not have any immich specific logic (that belongs insrc/services/)Please describe to which degree, if any, an LLM was used in creating this pull request.
N/A