diff --git a/lib/bloc/list_album.dart b/lib/bloc/list_album.dart index bedcedb2..6d63b574 100644 --- a/lib/bloc/list_album.dart +++ b/lib/bloc/list_album.dart @@ -205,13 +205,17 @@ class ListAlbumBloc extends Bloc { // no data in this bloc, ignore return; } - if (_isAccountOfInterest(ev.account) && - ev.destination - .startsWith(remote_storage_util.getRemoteAlbumsDir(ev.account))) { - _refreshThrottler.trigger( - maxResponceTime: const Duration(seconds: 3), - maxPendingCount: 10, - ); + if (_isAccountOfInterest(ev.account)) { + if (ev.destination + .startsWith(remote_storage_util.getRemoteAlbumsDir(ev.account)) || + ev.file.path + .startsWith(remote_storage_util.getRemoteAlbumsDir(ev.account))) { + // moving from/to album dir + _refreshThrottler.trigger( + maxResponceTime: const Duration(seconds: 3), + maxPendingCount: 10, + ); + } } } diff --git a/lib/bloc/list_sharing.dart b/lib/bloc/list_sharing.dart index 8fc08488..6dd815e3 100644 --- a/lib/bloc/list_sharing.dart +++ b/lib/bloc/list_sharing.dart @@ -270,14 +270,15 @@ class ListSharingBloc extends Bloc { // no data in this bloc, ignore return; } - // from pending dir to album dir - if (_isAccountOfInterest(ev.account) && - ev.file.path.startsWith( - remote_storage_util.getRemotePendingSharedAlbumsDir(ev.account)) && - ev.destination - .startsWith(remote_storage_util.getRemoteAlbumsDir(ev.account))) { - add(_ListSharingBlocPendingSharedAlbumMoved( - ev.account, ev.file, ev.destination)); + if (_isAccountOfInterest(ev.account)) { + if (ev.destination.startsWith(remote_storage_util + .getRemotePendingSharedAlbumsDir(ev.account)) && + ev.file.path.startsWith(remote_storage_util + .getRemotePendingSharedAlbumsDir(ev.account))) { + // moving from/to pending dir + add(_ListSharingBlocPendingSharedAlbumMoved( + ev.account, ev.file, ev.destination)); + } } } diff --git a/lib/use_case/unimport_shared_album.dart b/lib/use_case/unimport_shared_album.dart new file mode 100644 index 00000000..5b041fbf --- /dev/null +++ b/lib/use_case/unimport_shared_album.dart @@ -0,0 +1,23 @@ +import 'package:nc_photos/account.dart'; +import 'package:nc_photos/entity/album.dart'; +import 'package:nc_photos/entity/file.dart'; +import 'package:nc_photos/remote_storage_util.dart' as remote_storage_util; +import 'package:nc_photos/use_case/move.dart'; + +/// Unimport a shared album from the library +class UnimportSharedAlbum { + const UnimportSharedAlbum(this.fileRepo); + + Future call(Account account, Album album) async { + final destination = + "${remote_storage_util.getRemotePendingSharedAlbumsDir(account)}/${album.albumFile!.filename}"; + await Move(fileRepo)( + account, + album.albumFile!, + destination, + shouldCreateMissingDir: true, + ); + } + + final FileRepo fileRepo; +} diff --git a/lib/widget/home_albums.dart b/lib/widget/home_albums.dart index 6366c94e..025eeaed 100644 --- a/lib/widget/home_albums.dart +++ b/lib/widget/home_albums.dart @@ -22,6 +22,7 @@ import 'package:nc_photos/pref.dart'; import 'package:nc_photos/snack_bar_manager.dart'; import 'package:nc_photos/theme.dart'; import 'package:nc_photos/use_case/remove_album.dart'; +import 'package:nc_photos/use_case/unimport_shared_album.dart'; import 'package:nc_photos/widget/album_browser_util.dart' as album_browser_util; import 'package:nc_photos/widget/album_importer.dart'; import 'package:nc_photos/widget/album_search_delegate.dart'; @@ -405,8 +406,14 @@ class _HomeAlbumsState extends State final failures = []; for (final a in selectedAlbums) { try { - await RemoveAlbum(fileRepo, albumRepo, shareRepo, Pref())( - widget.account, a); + if (a.albumFile?.isOwned(widget.account.username) == true) { + // delete owned albums + await RemoveAlbum(fileRepo, albumRepo, shareRepo, Pref())( + widget.account, a); + } else { + // remove shared albums from collection + await UnimportSharedAlbum(fileRepo)(widget.account, a); + } } catch (e, stackTrace) { _log.shout( "[_onSelectionDeletePressed] Failed while removing album: '${a.name}'",