Skip to content

armgit / ente

Public Imported from GitHub
0

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

Guard stale UI handles after dismissal

Neeraj Gupta9297a3d0d2c2
diff --git a/mobile/apps/photos/lib/ui/common/progress_dialog.dart b/mobile/apps/photos/lib/ui/common/progress_dialog.dart
index e04e5efc5f..41da14956f 100644
--- a/mobile/apps/photos/lib/ui/common/progress_dialog.dart
+++ b/mobile/apps/photos/lib/ui/common/progress_dialog.dart
@@ -216,6 +216,7 @@ class _Body extends StatefulWidget {
class _BodyState extends State<_Body> {
void update() {
+ if (!mounted) return;
setState(() {});
}
diff --git a/mobile/apps/photos/lib/ui/payment/stripe_subscription_page.dart b/mobile/apps/photos/lib/ui/payment/stripe_subscription_page.dart
index 67d7e8e6ff..dcd9b10402 100644
--- a/mobile/apps/photos/lib/ui/payment/stripe_subscription_page.dart
+++ b/mobile/apps/photos/lib/ui/payment/stripe_subscription_page.dart
@@ -565,7 +565,7 @@ class _StripeSubscriptionPageState extends State<StripeSubscriptionPage> {
).areYouSureYouWantToChangeYourPlan,
firstButtonLabel: AppLocalizations.of(context).yes,
);
- if (result!.action == ButtonAction.first) {
+ if (result?.action == ButtonAction.first) {
stripPurChaseAction = 'update';
} else {
return;
diff --git a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
index 3d0414e53a..b1999092f8 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
@@ -465,6 +465,7 @@ class _BodyState extends State<_Body> {
}
Future<void> _onFileRemoved(EnteFile file) async {
+ if (!mounted || _files == null) return;
final totalFiles = _files!.length;
if (totalFiles == 1) {
// Deleted the only file
diff --git a/mobile/apps/photos/lib/ui/viewer/file/zoomable_live_image_new.dart b/mobile/apps/photos/lib/ui/viewer/file/zoomable_live_image_new.dart
index 6b9cdb6944..6a9d77bb10 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/zoomable_live_image_new.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/zoomable_live_image_new.dart
@@ -223,10 +223,10 @@ class _ZoomableLiveImageNewState extends State<ZoomableLiveImageNew>
? await _getLivePhotoVideo()
: await _getMotionPhotoVideo();
+ if (!mounted) return;
if (videoFile != null && videoFile.existsSync()) {
await _setVideoController(videoFile.path);
} else if (_enteFile.isLivePhoto) {
- if (!mounted) return;
showShortToast(context, AppLocalizations.of(context).downloadFailed);
}
} finally {
diff --git a/mobile/packages/lock_screen/lib/local_authentication_service.dart b/mobile/packages/lock_screen/lib/local_authentication_service.dart
index 3cc24e3112..ea8717cc20 100644
--- a/mobile/packages/lock_screen/lib/local_authentication_service.dart
+++ b/mobile/packages/lock_screen/lib/local_authentication_service.dart
@@ -40,7 +40,7 @@ class LocalAuthenticationService {
}
if (await isLocalAuthSupportedOnDevice() ||
LockScreenSettings.instance.getIsAppLockSet()) {
- AppLock.of(context)!.setEnabled(false);
+ AppLock.of(context)?.setEnabled(false);
bool result = false;
WindowsLocalAuthenticationException? windowsLocalAuthException;
LocalAuthenticationUnavailableException? localAuthUnavailableException;
@@ -61,7 +61,7 @@ class LocalAuthenticationService {
} finally {
AppLock.of(
context,
- )!.setEnabled(await LockScreenSettings.instance.shouldShowLockScreen());
+ )?.setEnabled(await LockScreenSettings.instance.shouldShowLockScreen());
if (refocusWindows) {
await PlatformUtil.refocusWindows();
}