mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
fix(mobile): avoid duplicate assets in album view (#28152)
fix(mobile): avoid duplicate assets in remote album timeline Co-authored-by: Stefan Friedli <stefan@stefanfriedli.ch>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:immich_mobile/domain/models/asset/base_asset.model.dart';
|
||||
import 'package:immich_mobile/domain/models/timeline.model.dart';
|
||||
import 'package:immich_mobile/infrastructure/repositories/timeline.repository.dart';
|
||||
|
||||
import '../repository_context.dart';
|
||||
|
||||
void main() {
|
||||
late MediumRepositoryContext ctx;
|
||||
late DriftTimelineRepository sut;
|
||||
|
||||
setUp(() {
|
||||
ctx = MediumRepositoryContext();
|
||||
sut = DriftTimelineRepository(ctx.db);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await ctx.dispose();
|
||||
});
|
||||
|
||||
group('remoteAlbum assets', () {
|
||||
test('no duplicate assets when identical checksum appears in multiple local asset rows', () async {
|
||||
// Regression check for #23273: a LEFT OUTER JOIN on checksum would fan out and create duplicates
|
||||
// happens when same photo exists in multiple albums on device
|
||||
final user = await ctx.newUser();
|
||||
final checksum = 'yolo';
|
||||
final album = await ctx.newRemoteAlbum(ownerId: user.id);
|
||||
final remoteAsset = await ctx.newRemoteAsset(ownerId: user.id, checksum: checksum);
|
||||
await ctx.insertRemoteAlbumAsset(albumId: album.id, assetId: remoteAsset.id);
|
||||
|
||||
final localAsset1 = await ctx.newLocalAsset(checksum: checksum);
|
||||
final localAsset2 = await ctx.newLocalAsset(checksum: checksum);
|
||||
|
||||
final assets = await sut.remoteAlbum(album.id, GroupAssetsBy.day).assetSource(0, 10);
|
||||
|
||||
expect(assets, hasLength(1));
|
||||
expect((assets.first as RemoteAsset).id, remoteAsset.id);
|
||||
expect([localAsset1.id, localAsset2.id], contains((assets.first as RemoteAsset).localId));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user