mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(mobile): add AssetState and proper asset updating (#2270)
* refactor(mobile): add AssetState and proper asset updating * generate files --------- Co-authored-by: Fynn Petersen-Frey <zoodyy@users.noreply.github.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
parent
b970a40b4e
commit
e80d37bf8f
14 changed files with 256 additions and 98 deletions
|
|
@ -136,7 +136,7 @@ class SyncService {
|
|||
if (match != null) {
|
||||
// unify local/remote assets by replacing the
|
||||
// local-only asset in the DB with a local&remote asset
|
||||
newAsset.updateFromDb(match);
|
||||
newAsset = match.updatedCopy(newAsset);
|
||||
}
|
||||
try {
|
||||
await _db.writeTxn(() => newAsset.put(_db));
|
||||
|
|
@ -581,12 +581,12 @@ class SyncService {
|
|||
// client and server, thus never reaching "both" case below
|
||||
compare: Asset.compareByOwnerDeviceLocalId,
|
||||
both: (Asset a, Asset b) {
|
||||
if ((a.isLocal || !b.isLocal) && (a.isRemote || !b.isRemote)) {
|
||||
if (a.canUpdate(b)) {
|
||||
toUpsert.add(a.updatedCopy(b));
|
||||
return true;
|
||||
} else {
|
||||
existing.add(a);
|
||||
return false;
|
||||
} else {
|
||||
toUpsert.add(b.updateFromDb(a));
|
||||
return true;
|
||||
}
|
||||
},
|
||||
onlyFirst: (Asset a) => _log.finer(
|
||||
|
|
@ -637,10 +637,8 @@ Triple<List<Asset>, List<Asset>, List<Asset>> _diffAssets(
|
|||
assets,
|
||||
compare: compare,
|
||||
both: (Asset a, Asset b) {
|
||||
if (a.updatedAt.isBefore(b.updatedAt) ||
|
||||
(!a.isLocal && b.isLocal) ||
|
||||
(!a.isRemote && b.isRemote)) {
|
||||
toUpdate.add(b.updateFromDb(a));
|
||||
if (a.canUpdate(b)) {
|
||||
toUpdate.add(a.updatedCopy(b));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue