mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 00:50:23 -05:00
fix(mobile): fetch non-archive for partners
This commit is contained in:
parent
f08e9a4447
commit
ee7e20706b
1 changed files with 16 additions and 5 deletions
|
@ -39,7 +39,7 @@ class AssetService {
|
||||||
|
|
||||||
/// Checks the server for updated assets and updates the local database if
|
/// Checks the server for updated assets and updates the local database if
|
||||||
/// required. Returns `true` if there were any changes.
|
/// required. Returns `true` if there were any changes.
|
||||||
Future<bool> refreshRemoteAssets([User? user]) async {
|
Future<bool> refreshRemoteAssets({User? user, bool isArchive = true}) async {
|
||||||
user ??= Store.get<User>(StoreKey.currentUser);
|
user ??= Store.get<User>(StoreKey.currentUser);
|
||||||
final Stopwatch sw = Stopwatch()..start();
|
final Stopwatch sw = Stopwatch()..start();
|
||||||
final bool changes = await _syncService.syncRemoteAssetsToDb(
|
final bool changes = await _syncService.syncRemoteAssetsToDb(
|
||||||
|
@ -53,12 +53,19 @@ class AssetService {
|
||||||
|
|
||||||
/// Returns `(null, null)` if changes are invalid -> requires full sync
|
/// Returns `(null, null)` if changes are invalid -> requires full sync
|
||||||
Future<(List<Asset>? toUpsert, List<String>? toDelete)>
|
Future<(List<Asset>? toUpsert, List<String>? toDelete)>
|
||||||
_getRemoteAssetChanges(User user, DateTime since) async {
|
_getRemoteAssetChanges(
|
||||||
|
User user,
|
||||||
|
DateTime since, {
|
||||||
|
bool isArchive = true,
|
||||||
|
}) async {
|
||||||
final deleted = await _apiService.auditApi
|
final deleted = await _apiService.auditApi
|
||||||
.getAuditDeletes(since, EntityType.ASSET, userId: user.id);
|
.getAuditDeletes(since, EntityType.ASSET, userId: user.id);
|
||||||
if (deleted == null || deleted.needsFullSync) return (null, null);
|
if (deleted == null || deleted.needsFullSync) return (null, null);
|
||||||
final assetDto = await _apiService.assetApi
|
final assetDto = await _apiService.assetApi.getAllAssets(
|
||||||
.getAllAssets(userId: user.id, updatedAfter: since);
|
userId: user.id,
|
||||||
|
updatedAfter: since,
|
||||||
|
isArchived: isArchive,
|
||||||
|
);
|
||||||
if (assetDto == null) return (null, null);
|
if (assetDto == null) return (null, null);
|
||||||
return (assetDto.map(Asset.remote).toList(), deleted.ids);
|
return (assetDto.map(Asset.remote).toList(), deleted.ids);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +92,10 @@ class AssetService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `null` if the server state did not change, else list of assets
|
/// Returns `null` if the server state did not change, else list of assets
|
||||||
Future<List<Asset>?> _getRemoteAssets(User user) async {
|
Future<List<Asset>?> _getRemoteAssets(
|
||||||
|
User user, {
|
||||||
|
bool isArchive = true,
|
||||||
|
}) async {
|
||||||
const int chunkSize = 10000;
|
const int chunkSize = 10000;
|
||||||
try {
|
try {
|
||||||
final DateTime now = DateTime.now().toUtc();
|
final DateTime now = DateTime.now().toUtc();
|
||||||
|
@ -101,6 +111,7 @@ class AssetService {
|
||||||
updatedBefore: now,
|
updatedBefore: now,
|
||||||
skip: i,
|
skip: i,
|
||||||
take: chunkSize,
|
take: chunkSize,
|
||||||
|
isArchived: isArchive,
|
||||||
);
|
);
|
||||||
if (assets == null) {
|
if (assets == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue