mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
fix(mobile): prevent asset loading issues when changing page or when closing memories (#27596)
This commit is contained in:
@@ -160,12 +160,25 @@ class DriftMemoryPage extends HookConsumerWidget {
|
|||||||
currentAssetPage.value = otherIndex;
|
currentAssetPage.value = otherIndex;
|
||||||
updateProgressText();
|
updateProgressText();
|
||||||
|
|
||||||
|
final activeMemory = currentMemory.value;
|
||||||
|
|
||||||
// Wait for page change animation to finish
|
// Wait for page change animation to finish
|
||||||
await Future.delayed(const Duration(milliseconds: 400));
|
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
|
// And then precache the next asset
|
||||||
await precacheAsset(otherIndex + 1);
|
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;
|
currentAsset.value = asset;
|
||||||
ref.read(assetViewerProvider.notifier).setAsset(asset);
|
ref.read(assetViewerProvider.notifier).setAsset(asset);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user