From e2b67a803d71da4e41f0fec0a068c93c3abf71da Mon Sep 17 00:00:00 2001 From: alper <29778028+iamalper@users.noreply.github.com> Date: Sun, 10 Sep 2023 21:57:28 +0300 Subject: [PATCH] fix: dont update ui for received files --- lib/screens/receive_page.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/screens/receive_page.dart b/lib/screens/receive_page.dart index 1b3115e..978cd0f 100644 --- a/lib/screens/receive_page.dart +++ b/lib/screens/receive_page.dart @@ -1,3 +1,4 @@ +import 'package:weepy/files_riverpod.dart'; import 'package:weepy/models.dart'; import '../classes/exceptions.dart'; @@ -5,6 +6,7 @@ import '../constants.dart'; import 'package:flutter/material.dart'; import '../classes/receiver.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; enum _UiState { loading, listening, downloading, complete, error } @@ -21,14 +23,14 @@ class ReceivePage extends StatelessWidget { } } -class ReceivePageInner extends StatefulWidget { +class ReceivePageInner extends ConsumerStatefulWidget { const ReceivePageInner({super.key}); @override - State createState() => _ReceivePageInnerState(); + ConsumerState createState() => _ReceivePageInnerState(); } -class _ReceivePageInnerState extends State +class _ReceivePageInnerState extends ConsumerState with TickerProviderStateMixin { late AnimationController _downloadAnimC; late Receiver _receiveClass; @@ -52,7 +54,8 @@ class _ReceivePageInnerState extends State _receiveClass = Receiver( downloadAnimC: _downloadAnimC, onDownloadStart: () => uiStatus = _UiState.downloading, - onAllFilesDownloaded: (files) { + onAllFilesDownloaded: (files) async { + await ref.read(filesProvider.notifier).addFiles(files); _files = files; uiStatus = _UiState.complete; },