1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-08 23:07:06 +02:00

refactor(mobile): assert lists are sorted for diffing (#13180)

This commit is contained in:
Fynn Petersen-Frey
2024-10-05 03:02:34 +02:00
committed by GitHub
parent 6bbaba7866
commit 0f3b8b67fe
2 changed files with 20 additions and 18 deletions

View File

@ -138,7 +138,6 @@ class SyncService {
Future<bool> _syncUsersFromServer(List<User> users) async {
users.sortBy((u) => u.id);
final dbUsers = await _userRepository.getAll(sortBy: UserSort.id);
assert(dbUsers.isSortedBy((u) => u.id), "dbUsers not sorted!");
final List<int> toDelete = [];
final List<User> toUpsert = [];
final changes = diffSortedListsSync(
@ -322,8 +321,6 @@ class SyncService {
ownerId: isShared ? null : me.isarId,
sortBy: AlbumSort.remoteId,
);
assert(dbAlbums.isSortedBy((e) => e.remoteId!), "dbAlbums not sorted!");
final List<Asset> toDelete = [];
final List<Asset> existing = [];
@ -512,7 +509,6 @@ class SyncService {
await _albumRepository.getAll(remote: false, sortBy: AlbumSort.localId);
final List<Asset> deleteCandidates = [];
final List<Asset> existing = [];
assert(inDb.isSorted((a, b) => a.localId!.compareTo(b.localId!)), "sort!");
final bool anyChanges = await diffSortedLists(
onDevice,
inDb,