Skip to content

armgit / ente

Public Imported from GitHub
0

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

Guard UI callbacks after async work

Neeraj Guptab38aadc55541
diff --git a/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart b/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart
index d4ffa62206..52e5962a60 100644
--- a/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/streaming/video_streaming_settings_page.dart
@@ -213,6 +213,7 @@ class VideoStreamingStatusWidgetState
Future<void> init() async {
_netProcessed = await VideoPreviewService.instance.getStatus();
+ if (!mounted) return;
setState(() {});
}
diff --git a/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart b/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart
index 98d3fef121..752b36f3a5 100644
--- a/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/actions/album_selection_action_widget.dart
@@ -262,12 +262,15 @@ class _AlbumSelectionActionWidgetState
continue;
}
count = await FilesDB.instance.collectionFileCount(collection.id);
+ if (!mounted) return;
final bool isEmptyCollection = count == 0;
if (isEmptyCollection) {
try {
await CollectionsService.instance.trashEmptyCollection(collection);
+ if (!mounted) return;
} catch (e, s) {
_logger.warning("failed to trash collection", e, s);
+ if (!mounted) return;
errors.add(e);
}
} else {
@@ -276,6 +279,7 @@ class _AlbumSelectionActionWidgetState
}
if (errors.isNotEmpty) {
await showGenericErrorDialog(context: context, error: errors.first);
+ if (!mounted) return;
}
if (nonEmptyCollection.isNotEmpty) {
@@ -287,6 +291,7 @@ class _AlbumSelectionActionWidgetState
debugPrint("Failed to delete collection");
}
}
+ if (!mounted) return;
if (hasFavorites) {
_showFavToast();
}
diff --git a/mobile/apps/photos/lib/ui/viewer/file/video_widget_native.dart b/mobile/apps/photos/lib/ui/viewer/file/video_widget_native.dart
index 425f23ccb6..03393de9fd 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/video_widget_native.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/video_widget_native.dart
@@ -278,6 +278,7 @@ class _VideoWidgetNativeState extends State<VideoWidgetNative>
}
void _onInteractionLockChanged(bool shouldLock) {
+ if (!mounted) return;
if (_isZooming != shouldLock) {
setState(() {
_isZooming = shouldLock;
diff --git a/mobile/apps/photos/lib/ui/viewer/file_details/preview_properties_item_widget.dart b/mobile/apps/photos/lib/ui/viewer/file_details/preview_properties_item_widget.dart
index cc0c2bf1fb..0a5e105648 100644
--- a/mobile/apps/photos/lib/ui/viewer/file_details/preview_properties_item_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file_details/preview_properties_item_widget.dart
@@ -41,6 +41,7 @@ class _PreviewPropertiesItemWidgetState
}
Future<void> _getSection() async {
+ if (!mounted) return;
final textStyle = getEnteTextTheme(context).miniMuted;
final subSectionWidgets = <Widget>[];
@@ -51,9 +52,11 @@ class _PreviewPropertiesItemWidgetState
return null;
});
- if (data!.width != null && data.height != null) {
+ if (!mounted || data == null) return;
+
+ if (data.width != null && data.height != null) {
subSectionWidgets.add(
- Text("${data.width!}x${data.height!}", style: textStyle),
+ Text("${data.width}x${data.height}", style: textStyle),
);
}