From 7f43c6a3a3c4ade7716bd1b4485f4a1e5b523e50 Mon Sep 17 00:00:00 2001 From: Luis Nachtigall <31982496+LeLunZ@users.noreply.github.com> Date: Thu, 7 May 2026 15:13:22 +0200 Subject: [PATCH] fix(mobile): prevent asset loading issues when changing page or when closing memories (#27596) --- .../lib/presentation/pages/drift_memory.page.dart | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/mobile/lib/presentation/pages/drift_memory.page.dart b/mobile/lib/presentation/pages/drift_memory.page.dart index 846f062501..6919925d55 100644 --- a/mobile/lib/presentation/pages/drift_memory.page.dart +++ b/mobile/lib/presentation/pages/drift_memory.page.dart @@ -160,12 +160,25 @@ class DriftMemoryPage extends HookConsumerWidget { currentAssetPage.value = otherIndex; updateProgressText(); + final activeMemory = currentMemory.value; + // Wait for page change animation to finish await Future.delayed(const Duration(milliseconds: 400)); + + // check if memory is still the same and if context is still mounted + if (currentMemory.value != activeMemory || !context.mounted) { + return; + } + // And then precache the next asset await precacheAsset(otherIndex + 1); - final asset = currentMemory.value.assets[otherIndex]; + // check again as precache involves async operations + if (currentMemory.value != activeMemory || !context.mounted) { + return; + } + + final asset = activeMemory.assets[otherIndex]; currentAsset.value = asset; ref.read(assetViewerProvider.notifier).setAsset(asset); }