Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix: show newly created album in the collection sheet for batch operation

AmanRajSinghMouryaab3808adbf06
diff --git a/mobile/lib/events/create_new_album_event.dart b/mobile/lib/events/create_new_album_event.dart
new file mode 100644
index 0000000000..390d69bcee
--- /dev/null
+++ b/mobile/lib/events/create_new_album_event.dart
@@ -0,0 +1,3 @@
+import "package:photos/events/event.dart";
+
+class CreateNewAlbumEvent extends Event {}
\ No newline at end of file
diff --git a/mobile/lib/ui/collections/album/vertical_list.dart b/mobile/lib/ui/collections/album/vertical_list.dart
index 321b62e9b9..4316b2475a 100644
--- a/mobile/lib/ui/collections/album/vertical_list.dart
+++ b/mobile/lib/ui/collections/album/vertical_list.dart
@@ -5,6 +5,7 @@ import "package:flutter/services.dart";
import 'package:logging/logging.dart';
import 'package:photos/core/configuration.dart';
import "package:photos/core/event_bus.dart";
+import "package:photos/events/create_new_album_event.dart";
import "package:photos/events/tab_changed_event.dart";
import "package:photos/generated/l10n.dart";
import 'package:photos/models/collection/collection.dart';
@@ -183,31 +184,35 @@ class _AlbumVerticalListWidgetState extends State<AlbumVerticalListWidget> {
}
if (collection != null) {
- if (await _runCollectionAction(
- context,
- collection,
- showProgressDialog: false,
- )) {
- if (widget.actionType == CollectionActionType.restoreFiles) {
- showShortToast(
- context,
- 'Restored files to album ' + albumName,
- );
- } else {
- showShortToast(
+ if (widget.enableSelection) {
+ Bus.instance.fire(CreateNewAlbumEvent());
+ } else {
+ if (await _runCollectionAction(
+ context,
+ collection,
+ showProgressDialog: false,
+ )) {
+ if (widget.actionType == CollectionActionType.restoreFiles) {
+ showShortToast(
+ context,
+ 'Restored files to album ' + albumName,
+ );
+ } else {
+ showShortToast(
+ context,
+ "Album '" + albumName + "' created.",
+ );
+ }
+
+ Navigator.pop(context);
+ Navigator.pop(context);
+
+ await _navigateToCollection(
context,
- "Album '" + albumName + "' created.",
+ collection,
+ hasVerifiedLock: hasVerifiedLock,
);
}
-
- Navigator.pop(context);
- Navigator.pop(context);
-
- await _navigateToCollection(
- context,
- collection,
- hasVerifiedLock: hasVerifiedLock,
- );
}
}
}
diff --git a/mobile/lib/ui/collections/collection_action_sheet.dart b/mobile/lib/ui/collections/collection_action_sheet.dart
index f056dc9732..8861804207 100644
--- a/mobile/lib/ui/collections/collection_action_sheet.dart
+++ b/mobile/lib/ui/collections/collection_action_sheet.dart
@@ -5,6 +5,8 @@ import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
import "package:photos/core/configuration.dart";
+import "package:photos/core/event_bus.dart";
+import "package:photos/events/create_new_album_event.dart";
import "package:photos/generated/l10n.dart";
import 'package:photos/models/collection/collection.dart';
import 'package:photos/models/selected_files.dart';
@@ -123,6 +125,7 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
static const int okButtonSize = 80;
String _searchQuery = "";
final _selectedCollections = <Collection>[];
+ late StreamSubscription<CreateNewAlbumEvent> _createNewAlbumSubscription;
@override
void initState() {
@@ -133,6 +136,14 @@ class _CollectionActionSheetState extends State<CollectionActionSheet> {
_enableSelection = (widget.actionType == CollectionActionType.addFiles ||
widget.actionType == CollectionActionType.addToHiddenAlbum) &&
(widget.sharedFiles == null || widget.sharedFiles!.isEmpty);
+ _createNewAlbumSubscription =
+ Bus.instance.on<CreateNewAlbumEvent>().listen((event) {});
+ }
+
+ @override
+ void dispose() {
+ _createNewAlbumSubscription.cancel();
+ super.dispose();
}
@override