diff --git a/lib/bloc/list_album.dart b/lib/bloc/list_album.dart index 218eb622..9a1b5f6c 100644 --- a/lib/bloc/list_album.dart +++ b/lib/bloc/list_album.dart @@ -89,15 +89,12 @@ class ListAlbumBlocInconsistent extends ListAlbumBlocState { class ListAlbumBloc extends Bloc { ListAlbumBloc() : super(ListAlbumBlocInit()) { - _filePropertyUpdatedListener = - AppEventListener(_onFilePropertyUpdatedEvent); _albumUpdatedListener = AppEventListener(_onAlbumUpdatedEvent); _fileRemovedListener = AppEventListener(_onFileRemovedEvent); _albumCreatedListener = AppEventListener(_onAlbumCreatedEvent); - _filePropertyUpdatedListener.begin(); _albumUpdatedListener.begin(); _fileRemovedListener.begin(); _albumCreatedListener.begin(); @@ -115,7 +112,6 @@ class ListAlbumBloc extends Bloc { @override close() { - _filePropertyUpdatedListener.end(); _albumUpdatedListener.end(); _fileRemovedListener.end(); _albumCreatedListener.end(); @@ -160,18 +156,6 @@ class ListAlbumBloc extends Bloc { yield ListAlbumBlocInconsistent(state.account, state.albums); } - void _onFilePropertyUpdatedEvent(FilePropertyUpdatedEvent ev) { - if (!ev.hasAnyProperties([FilePropertyUpdatedEvent.propMetadata])) { - // not interested - return; - } - if (state is ListAlbumBlocInit) { - // no data in this bloc, ignore - return; - } - add(_ListAlbumBlocExternalEvent()); - } - void _onAlbumUpdatedEvent(AlbumUpdatedEvent ev) { if (state is ListAlbumBlocInit) { // no data in this bloc, ignore @@ -224,7 +208,6 @@ class ListAlbumBloc extends Bloc { } } - AppEventListener _filePropertyUpdatedListener; AppEventListener _albumUpdatedListener; AppEventListener _fileRemovedListener; AppEventListener _albumCreatedListener; diff --git a/lib/use_case/update_missing_metadata.dart b/lib/use_case/update_missing_metadata.dart index 6715e308..fc7a608f 100644 --- a/lib/use_case/update_missing_metadata.dart +++ b/lib/use_case/update_missing_metadata.dart @@ -1,7 +1,6 @@ import 'package:logging/logging.dart'; import 'package:nc_photos/account.dart'; import 'package:nc_photos/connectivity_util.dart' as connectivity_util; -import 'package:nc_photos/entity/album.dart'; import 'package:nc_photos/entity/exif.dart'; import 'package:nc_photos/entity/file.dart'; import 'package:nc_photos/entity/file/data_source.dart'; @@ -52,8 +51,7 @@ class UpdateMissingMetadata { exif: exif, ); - final updateOp = UpdateProperty(FileRepo(FileCachedDataSource()), - AlbumRepo(AlbumCachedDataSource())); + final updateOp = UpdateProperty(FileRepo(FileCachedDataSource())); await updateOp( account, file, diff --git a/lib/use_case/update_property.dart b/lib/use_case/update_property.dart index d1c25736..8c062853 100644 --- a/lib/use_case/update_property.dart +++ b/lib/use_case/update_property.dart @@ -2,15 +2,12 @@ import 'package:event_bus/event_bus.dart'; import 'package:kiwi/kiwi.dart'; import 'package:logging/logging.dart'; import 'package:nc_photos/account.dart'; -import 'package:nc_photos/entity/album.dart'; import 'package:nc_photos/entity/file.dart'; import 'package:nc_photos/event/event.dart'; import 'package:nc_photos/or_null.dart'; -import 'package:nc_photos/use_case/list_album.dart'; -import 'package:nc_photos/use_case/update_album.dart'; class UpdateProperty { - UpdateProperty(this.fileRepo, this.albumRepo); + UpdateProperty(this.fileRepo); Future call( Account account, @@ -34,12 +31,6 @@ class UpdateProperty { metadata: metadata, isArchived: isArchived, ); - await _cleanUpAlbums( - account, - file, - metadata: metadata, - isArchived: isArchived, - ); int properties = 0; if (metadata != null) { @@ -54,41 +45,7 @@ class UpdateProperty { .fire(FilePropertyUpdatedEvent(account, file, properties)); } - Future _cleanUpAlbums( - Account account, - File file, { - OrNull metadata, - OrNull isArchived, - }) async { - final albums = await ListAlbum(fileRepo, albumRepo)(account); - for (final a in albums) { - try { - if (a.items.any((element) => - element is AlbumFileItem && element.file.path == file.path)) { - final newItems = a.items.map((e) { - if (e is AlbumFileItem && e.file.path == file.path) { - return AlbumFileItem( - file: e.file.copyWith( - metadata: metadata, - isArchived: isArchived, - ), - ); - } else { - return e; - } - }).toList(); - await UpdateAlbum(albumRepo)(account, a.copyWith(items: newItems)); - } - } catch (e, stacktrace) { - _log.shout( - "[_cleanUpAlbums] Failed while updating album", e, stacktrace); - // continue to next album - } - } - } - final FileRepo fileRepo; - final AlbumRepo albumRepo; static final _log = Logger("use_case.update_property.UpdateProperty"); } diff --git a/lib/widget/archive_viewer.dart b/lib/widget/archive_viewer.dart index 299188fd..f01d5b7a 100644 --- a/lib/widget/archive_viewer.dart +++ b/lib/widget/archive_viewer.dart @@ -7,7 +7,6 @@ import 'package:logging/logging.dart'; import 'package:nc_photos/account.dart'; import 'package:nc_photos/api/api_util.dart' as api_util; import 'package:nc_photos/bloc/scan_dir.dart'; -import 'package:nc_photos/entity/album.dart'; import 'package:nc_photos/entity/file.dart'; import 'package:nc_photos/entity/file/data_source.dart'; import 'package:nc_photos/entity/file_util.dart' as file_util; @@ -216,11 +215,10 @@ class _ArchiveViewerState extends State clearSelectedItems(); }); final fileRepo = FileRepo(FileCachedDataSource()); - final albumRepo = AlbumRepo(AlbumCachedDataSource()); final failures = []; for (final f in selectedFiles) { try { - await UpdateProperty(fileRepo, albumRepo) + await UpdateProperty(fileRepo) .updateIsArchived(widget.account, f, false); } catch (e, stacktrace) { _log.shout( diff --git a/lib/widget/home_photos.dart b/lib/widget/home_photos.dart index bc8aaa74..44dd82a3 100644 --- a/lib/widget/home_photos.dart +++ b/lib/widget/home_photos.dart @@ -408,11 +408,10 @@ class _HomePhotosState extends State clearSelectedItems(); }); final fileRepo = FileRepo(FileCachedDataSource()); - final albumRepo = AlbumRepo(AlbumCachedDataSource()); final failures = []; for (final f in selectedFiles) { try { - await UpdateProperty(fileRepo, albumRepo) + await UpdateProperty(fileRepo) .updateIsArchived(widget.account, f, true); } catch (e, stacktrace) { _log.shout(