use asynccache

This commit is contained in:
shenlong-tanwen
2024-11-24 22:32:21 +05:30
parent 8450c8cc4f
commit 0e8b19e269
8 changed files with 35 additions and 23 deletions
@@ -1,3 +1,4 @@
import 'package:async/async.dart';
import 'package:immich_mobile/domain/interfaces/album.interface.dart';
import 'package:immich_mobile/domain/interfaces/album_asset.interface.dart';
import 'package:immich_mobile/domain/interfaces/album_etag.interface.dart';
@@ -14,10 +15,13 @@ import 'package:immich_mobile/utils/isolate_helper.dart';
import 'package:immich_mobile/utils/mixins/log.mixin.dart';
class AlbumSyncService with LogMixin {
const AlbumSyncService();
AlbumSyncService();
final _fullDeviceSyncCache = AsyncCache<bool>.ephemeral();
Future<bool> performFullDeviceSyncIsolate() async {
return await IsolateHelper.run(performFullDeviceSync);
return await _fullDeviceSyncCache
.fetch(() async => await IsolateHelper.run(performFullDeviceSync));
}
Future<bool> performFullDeviceSync() async {