2021-09-29 13:00:00 +02:00
|
|
|
import 'package:nc_photos/account.dart';
|
2021-11-01 10:50:13 +01:00
|
|
|
import 'package:nc_photos/app_db.dart';
|
2021-09-29 13:00:00 +02:00
|
|
|
import 'package:nc_photos/entity/album.dart';
|
|
|
|
import 'package:nc_photos/entity/album/item.dart';
|
|
|
|
import 'package:nc_photos/entity/album/provider.dart';
|
|
|
|
import 'package:nc_photos/use_case/populate_album.dart';
|
|
|
|
import 'package:nc_photos/use_case/resync_album.dart';
|
|
|
|
|
|
|
|
/// Pre-process an album such that it's ready to be displayed
|
|
|
|
///
|
|
|
|
/// Internally, it'll dispatch the work depending on the album:
|
|
|
|
/// - with AlbumStaticProvider: [ResyncAlbum]
|
|
|
|
/// - with AlbumDirProvider: [PopulateAlbum]
|
|
|
|
class PreProcessAlbum {
|
2021-11-01 10:50:13 +01:00
|
|
|
const PreProcessAlbum(this.appDb);
|
|
|
|
|
2021-09-29 13:00:00 +02:00
|
|
|
Future<List<AlbumItem>> call(Account account, Album album) {
|
|
|
|
if (album.provider is AlbumStaticProvider) {
|
2021-11-01 10:50:13 +01:00
|
|
|
return ResyncAlbum(appDb)(account, album);
|
2022-01-15 11:35:15 +01:00
|
|
|
} else if (album.provider is AlbumDynamicProvider ||
|
|
|
|
album.provider is AlbumSmartProvider) {
|
2021-11-01 10:50:13 +01:00
|
|
|
return PopulateAlbum(appDb)(account, album);
|
2021-09-29 13:00:00 +02:00
|
|
|
} else {
|
|
|
|
throw ArgumentError(
|
|
|
|
"Unknown album provider: ${album.provider.runtimeType}");
|
|
|
|
}
|
|
|
|
}
|
2021-11-01 10:50:13 +01:00
|
|
|
|
|
|
|
final AppDb appDb;
|
2021-09-29 13:00:00 +02:00
|
|
|
}
|