fix(mobile): prevent asset loading issues when changing page or when closing memories (#27596)

This commit is contained in:
Luis Nachtigall
2026-05-07 15:13:22 +02:00
committed by GitHub
parent 87175ee56c
commit 7f43c6a3a3
@@ -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);
}