Fix removing file from Nextcloud album incorrectly deleted it

This commit is contained in:
Ming Ming 2023-09-13 01:28:09 +08:00
parent bfbfaffe5c
commit 1cfff45039
3 changed files with 60 additions and 1 deletions

View file

@ -53,7 +53,14 @@ class CollectionNcAlbumAdapter
); );
return items.map((i) { return items.map((i) {
final f = found.firstWhereOrNull((e) => e.fdId == i.fileId); final f = found.firstWhereOrNull((e) => e.fdId == i.fileId);
return CollectionFileItemNcAlbumItemAdapter(i, f); return CollectionFileItemNcAlbumItemAdapter(
i,
// retain the path such that it is correct recognized as part of an
// album
f?.copyWith(
fdPath: i.path,
),
);
}).toList(); }).toList();
}); });
} }

View file

@ -1,3 +1,4 @@
import 'package:copy_with/copy_with.dart';
import 'package:equatable/equatable.dart'; import 'package:equatable/equatable.dart';
import 'package:nc_photos/entity/file.dart'; import 'package:nc_photos/entity/file.dart';
import 'package:np_common/type.dart'; import 'package:np_common/type.dart';
@ -18,6 +19,7 @@ int compareFileDescriptorDateTimeDescending(
} }
} }
@genCopyWith
@toString @toString
class FileDescriptor with EquatableMixin { class FileDescriptor with EquatableMixin {
const FileDescriptor({ const FileDescriptor({

View file

@ -2,6 +2,56 @@
part of 'file_descriptor.dart'; part of 'file_descriptor.dart';
// **************************************************************************
// CopyWithLintRuleGenerator
// **************************************************************************
// ignore_for_file: library_private_types_in_public_api, duplicate_ignore
// **************************************************************************
// CopyWithGenerator
// **************************************************************************
abstract class $FileDescriptorCopyWithWorker {
FileDescriptor call(
{String? fdPath,
int? fdId,
String? fdMime,
bool? fdIsArchived,
bool? fdIsFavorite,
DateTime? fdDateTime});
}
class _$FileDescriptorCopyWithWorkerImpl
implements $FileDescriptorCopyWithWorker {
_$FileDescriptorCopyWithWorkerImpl(this.that);
@override
FileDescriptor call(
{dynamic fdPath,
dynamic fdId,
dynamic fdMime = copyWithNull,
dynamic fdIsArchived,
dynamic fdIsFavorite,
dynamic fdDateTime}) {
return FileDescriptor(
fdPath: fdPath as String? ?? that.fdPath,
fdId: fdId as int? ?? that.fdId,
fdMime: fdMime == copyWithNull ? that.fdMime : fdMime as String?,
fdIsArchived: fdIsArchived as bool? ?? that.fdIsArchived,
fdIsFavorite: fdIsFavorite as bool? ?? that.fdIsFavorite,
fdDateTime: fdDateTime as DateTime? ?? that.fdDateTime);
}
final FileDescriptor that;
}
extension $FileDescriptorCopyWith on FileDescriptor {
$FileDescriptorCopyWithWorker get copyWith => _$copyWith;
$FileDescriptorCopyWithWorker get _$copyWith =>
_$FileDescriptorCopyWithWorkerImpl(this);
}
// ************************************************************************** // **************************************************************************
// ToStringGenerator // ToStringGenerator
// ************************************************************************** // **************************************************************************