Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile][photos] update usage of new split trash file classes

Priyanshu Dangarea2a7bfaffb78
diff --git a/mobile/apps/photos/lib/models/file/trash_file.dart b/mobile/apps/photos/lib/models/file/trash_file.dart
index b123346f12..53d6bfd9a2 100644
--- a/mobile/apps/photos/lib/models/file/trash_file.dart
+++ b/mobile/apps/photos/lib/models/file/trash_file.dart
@@ -34,6 +34,8 @@ class EnteTrashFile extends TrashFile {
class DeviceTrashFile extends TrashFile {
DeviceTrashFile();
+
+ DeviceTrashFile.from(super.file, {required super.deleteBy}) : super.from();
}
AssetEntity trashFileToAssetEntity(EnteFile file) {
diff --git a/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart b/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart
index bfb7442ea0..0489410294 100644
--- a/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/actions/file_selection_actions_widget.dart
@@ -1093,7 +1093,7 @@ class _FileSelectionActionsWidgetState
void _restore() {
final isDeviceOnly = widget.selectedFiles.files.every(
- (f) => f.isDeviceOnlyTrashFile,
+ (f) => f.isDeviceTrash,
);
if (isDeviceOnly) {
_restoreFilesFromDeviceTrash(widget.selectedFiles).onError((e, s) {
@@ -1111,7 +1111,7 @@ class _FileSelectionActionsWidgetState
Future<void> _permanentlyDeleteFromTrash() async {
final isDeviceOnly = widget.selectedFiles.files.every(
- (f) => f.isDeviceOnlyTrashFile,
+ (f) => f.isDeviceTrash,
);
if (isDeviceOnly) {
await permanentlyDeleteFromDeviceTrash(context, widget.selectedFiles);
@@ -1119,7 +1119,7 @@ class _FileSelectionActionsWidgetState
}
if (await deleteFromEnteTrash(
context,
- widget.selectedFiles.files.toList(),
+ widget.selectedFiles.files.whereType<EnteTrashFile>().toList(),
)) {
widget.selectedFiles.clearAll();
}
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
index 1901560473..7cdcf106a0 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
@@ -289,7 +289,7 @@ class FileAppBarState extends State<FileAppBar> {
);
}
- if (!isFileUploaded && !widget.file.isTrashFile && !isLocalGalleryMode) {
+ if (!isFileUploaded && !widget.file.isTrash && !isLocalGalleryMode) {
_actions.add(
UploadIconWidget(file: widget.file, key: ValueKey(widget.file.tag)),
);
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart b/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart
index 7a7d2f4473..6134089d08 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_bottom_bar.dart
@@ -242,7 +242,7 @@ class FileBottomBarState extends State<FileBottomBar> {
child: IconButton(
icon: const Icon(CupertinoIcons.gobackward, color: Colors.white),
onPressed: () {
- if (widget.file.isDeviceOnlyTrashFile) {
+ if (widget.file.isDeviceTrash) {
_restoreFromDeviceTrash().onError((e, s) {
if (!mounted) return;
showGenericErrorDialog(context: context, error: e).ignore();
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart
index db57a6c831..22fa9edfcb 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_details_widget.dart
@@ -103,7 +103,7 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
}
});
- if (!widget.file.isDeviceOnlyTrashFile) {
+ if (!widget.file.isDeviceTrash) {
if (_isImage) {
_exifNotifier.addListener(() {
if (_exifNotifier.value != null) {
@@ -231,7 +231,7 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
]);
}
- if (_isImage && !file.isDeviceOnlyTrashFile) {
+ if (_isImage && !file.isDeviceTrash) {
fileDetailsTiles.addAll([
MenuGroupComponent(
items: [
@@ -260,7 +260,7 @@ class _FileDetailsWidgetState extends State<FileDetailsWidget> {
_exifData,
_currentUserID,
),
- if (flagService.internalUser && !file.isDeviceOnlyTrashFile)
+ if (flagService.internalUser && !file.isDeviceTrash)
ValueListenableBuilder(
valueListenable: _videoMetadataNotifier,
builder: (context, value, _) => VideoExifRowItem(file, value),
diff --git a/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart b/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart
index 6e9eefe471..e3ac47da12 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/zoomable_image.dart
@@ -389,9 +389,7 @@ class _ZoomableImageState extends State<ZoomableImage> {
});
}
- if (!_loadingFinalImage &&
- !_loadedFinalImage &&
- !_photo.isDeviceOnlyTrashFile) {
+ if (!_loadingFinalImage && !_loadedFinalImage && !_photo.isDeviceTrash) {
_loadingFinalImage = true;
getFile(
_photo,
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/trash_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/trash_page.dart
index 2a3be848c9..bd9300105c 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/trash_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/trash_page.dart
@@ -167,12 +167,9 @@ class _TrashPageState extends State<_TrashPage> {
final asset = deviceTrashAssets[i];
if (asset == null) continue;
files.add(
- TrashFile.fromEnteFile(
+ DeviceTrashFile.from(
fileFromAsset(trash.deviceFolder, asset),
- createdAt: trash.deleteBy - const Duration(days: 30).inMicroseconds,
- updateAt: trash.deleteBy - const Duration(days: 30).inMicroseconds,
deleteBy: trash.deleteBy,
- isDeviceOnly: true,
),
);
}