Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix black screen on collection deletion

vishnukvmde619ef387c5f
diff --git a/mobile/apps/locker/lib/ui/pages/collection_page.dart b/mobile/apps/locker/lib/ui/pages/collection_page.dart
index c2b9f210a6..11ef07e274 100644
--- a/mobile/apps/locker/lib/ui/pages/collection_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/collection_page.dart
@@ -46,6 +46,9 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>
final _logger = Logger("CollectionPage");
late StreamSubscription<CollectionsUpdatedEvent>
_collectionUpdateSubscription;
+ bool _isCollectionDeleted = false;
+ bool _isDeletingCollection = false;
+ bool _ignoreCollectionUpdates = false;
late Collection _collection;
List<EnteFile> _files = [];
@@ -111,6 +114,9 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>
_initializeData(widget.collection);
_collectionUpdateSubscription =
Bus.instance.on<CollectionsUpdatedEvent>().listen((event) async {
+ if (_ignoreCollectionUpdates || _isCollectionDeleted) {
+ return;
+ }
_logger.info(
"CollectionsUpdatedEvent received on CollectionPage (${widget.collection.id}): ${event.source}",
);
@@ -129,7 +135,7 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>
_logger.warning(
'Collection ${widget.collection.id} no longer exists, navigating back',
);
- if (mounted) {
+ if (!_isCollectionDeleted && mounted) {
Navigator.of(context).pop();
}
}
@@ -153,7 +159,30 @@ class _CollectionPageState extends UploaderPageState<CollectionPage>
}
Future<void> _deleteCollection() async {
- await CollectionActions.deleteCollection(context, _collection);
+ if (_isDeletingCollection) {
+ return;
+ }
+ _isDeletingCollection = true;
+ _ignoreCollectionUpdates = true;
+ var didDelete = false;
+ try {
+ await CollectionActions.deleteCollection(
+ context,
+ _collection,
+ onSuccess: () {
+ didDelete = true;
+ _isCollectionDeleted = true;
+ if (mounted) {
+ Navigator.of(context).pop();
+ }
+ },
+ );
+ } finally {
+ if (!didDelete) {
+ _ignoreCollectionUpdates = false;
+ }
+ _isDeletingCollection = false;
+ }
}
Future<void> _editCollection() async {