mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 18:38:48 +01:00
Remove shared album from collection when deleting
This commit is contained in:
parent
ba7e621588
commit
667d0395ec
4 changed files with 52 additions and 17 deletions
|
@ -205,13 +205,17 @@ class ListAlbumBloc extends Bloc<ListAlbumBlocEvent, ListAlbumBlocState> {
|
|||
// 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,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -270,14 +270,15 @@ class ListSharingBloc extends Bloc<ListSharingBlocEvent, ListSharingBlocState> {
|
|||
// 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
23
lib/use_case/unimport_shared_album.dart
Normal file
23
lib/use_case/unimport_shared_album.dart
Normal file
|
@ -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<void> 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;
|
||||
}
|
|
@ -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<HomeAlbums>
|
|||
final failures = <Album>[];
|
||||
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}'",
|
||||
|
|
Loading…
Reference in a new issue