mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-10 17:28:56 +01:00
Act according to album content instead of the pref flag
This commit is contained in:
parent
f384c6483f
commit
35e49c2bfd
3 changed files with 4 additions and 11 deletions
|
@ -52,7 +52,7 @@ class AddToAlbum {
|
||||||
);
|
);
|
||||||
await UpdateAlbum(albumRepo)(account, newAlbum);
|
await UpdateAlbum(albumRepo)(account, newAlbum);
|
||||||
|
|
||||||
if (pref.isLabEnableSharedAlbumOr(false)) {
|
if (album.shares?.isNotEmpty == true) {
|
||||||
final newFiles =
|
final newFiles =
|
||||||
items.whereType<AlbumFileItem>().map((e) => e.file).toList();
|
items.whereType<AlbumFileItem>().map((e) => e.file).toList();
|
||||||
if (newFiles.isNotEmpty) {
|
if (newFiles.isNotEmpty) {
|
||||||
|
@ -65,9 +65,6 @@ class AddToAlbum {
|
||||||
|
|
||||||
Future<void> _shareFiles(
|
Future<void> _shareFiles(
|
||||||
Account account, Album album, List<File> files) async {
|
Account account, Album album, List<File> files) async {
|
||||||
if (album.shares?.isNotEmpty != true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final albumShares = (album.shares!.map((e) => e.userId).toList()
|
final albumShares = (album.shares!.map((e) => e.userId).toList()
|
||||||
..add(album.albumFile!.ownerId ?? account.username))
|
..add(album.albumFile!.ownerId ?? account.username))
|
||||||
.where((element) => element != account.username)
|
.where((element) => element != account.username)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class RemoveAlbum {
|
||||||
/// Remove an album
|
/// Remove an album
|
||||||
Future<void> call(Account account, Album album) async {
|
Future<void> call(Account account, Album album) async {
|
||||||
_log.info("[call] Remove album: $album");
|
_log.info("[call] Remove album: $album");
|
||||||
if (pref.isLabEnableSharedAlbumOr(false)) {
|
if (album.shares?.isNotEmpty == true) {
|
||||||
// remove shares from the album json. This should be the first so if this
|
// remove shares from the album json. This should be the first so if this
|
||||||
// fail the whole op can fail safely
|
// fail the whole op can fail safely
|
||||||
await UpdateAlbum(albumRepo)(
|
await UpdateAlbum(albumRepo)(
|
||||||
|
@ -39,8 +39,7 @@ class RemoveAlbum {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _unshareFiles(Account account, Album album) async {
|
Future<void> _unshareFiles(Account account, Album album) async {
|
||||||
if (album.shares?.isNotEmpty != true ||
|
if (album.provider is! AlbumStaticProvider) {
|
||||||
album.provider is! AlbumStaticProvider) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final albumShares = (album.shares!.map((e) => e.userId).toList()
|
final albumShares = (album.shares!.map((e) => e.userId).toList()
|
||||||
|
|
|
@ -38,7 +38,7 @@ class RemoveFromAlbum {
|
||||||
newAlbum = await _fixAlbumPostRemove(account, newAlbum, items);
|
newAlbum = await _fixAlbumPostRemove(account, newAlbum, items);
|
||||||
await UpdateAlbum(albumRepo)(account, newAlbum);
|
await UpdateAlbum(albumRepo)(account, newAlbum);
|
||||||
|
|
||||||
if (pref.isLabEnableSharedAlbumOr(false)) {
|
if (album.shares?.isNotEmpty == true) {
|
||||||
final removeFiles =
|
final removeFiles =
|
||||||
items.whereType<AlbumFileItem>().map((e) => e.file).toList();
|
items.whereType<AlbumFileItem>().map((e) => e.file).toList();
|
||||||
if (removeFiles.isNotEmpty) {
|
if (removeFiles.isNotEmpty) {
|
||||||
|
@ -89,9 +89,6 @@ class RemoveFromAlbum {
|
||||||
|
|
||||||
Future<void> _unshareFiles(
|
Future<void> _unshareFiles(
|
||||||
Account account, Album album, List<File> files) async {
|
Account account, Album album, List<File> files) async {
|
||||||
if (album.shares?.isNotEmpty != true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final albumShares = (album.shares!.map((e) => e.userId).toList()
|
final albumShares = (album.shares!.map((e) => e.userId).toList()
|
||||||
..add(album.albumFile!.ownerId ?? account.username))
|
..add(album.albumFile!.ownerId ?? account.username))
|
||||||
.where((element) => element != account.username)
|
.where((element) => element != account.username)
|
||||||
|
|
Loading…
Reference in a new issue