fix(mobile): first video memory on page doesn't play (#23906)

* fix(mobile): first video memory doesn't play

* refactor: moved logic to static method

* refactor: fix haptic feedback & empty check

* refactor: use DriftMemory on setMemory

* refactor: move video reset into if block
This commit is contained in:
Yaros
2025-11-21 16:11:30 +01:00
committed by GitHub
parent 1dbc20fd77
commit 9f3eeed091
2 changed files with 16 additions and 10 deletions

View File

@@ -24,6 +24,16 @@ class DriftMemoryPage extends HookConsumerWidget {
const DriftMemoryPage({required this.memories, required this.memoryIndex, super.key});
static void setMemory(WidgetRef ref, DriftMemory memory) {
if (memory.assets.isNotEmpty) {
ref.read(currentAssetNotifier.notifier).setAsset(memory.assets.first);
if (memory.assets.first.isVideo) {
ref.read(videoPlaybackValueProvider.notifier).reset();
}
}
}
@override
Widget build(BuildContext context, WidgetRef ref) {
final currentMemory = useState(memories[memoryIndex]);
@@ -202,6 +212,10 @@ class DriftMemoryPage extends HookConsumerWidget {
if (pageNumber < memories.length) {
currentMemoryIndex.value = pageNumber;
currentMemory.value = memories[pageNumber];
WidgetsBinding.instance.addPostFrameCallback((_) {
DriftMemoryPage.setMemory(ref, memories[pageNumber]);
});
}
currentAssetPage.value = 0;