diff --git a/flutter/lib/pages/message_list/message_list.dart b/flutter/lib/pages/message_list/message_list.dart index 44fca48..8e91212 100644 --- a/flutter/lib/pages/message_list/message_list.dart +++ b/flutter/lib/pages/message_list/message_list.dart @@ -27,6 +27,8 @@ class MessageListPage extends StatefulWidget { class _MessageListPageState extends State with RouteAware { static const _pageSize = 128; + late final AppLifecycleListener _lifecyleListener; + PagingController _pagingController = PagingController.fromValue(PagingState(nextPageKey: null, itemList: [], error: null), firstPageKey: '@start'); Map? _channels = null; @@ -40,6 +42,10 @@ class _MessageListPageState extends State with RouteAware { _pagingController.addPageRequestListener(_fetchPage); if (widget.isVisiblePage && !_isInitialized) _realInitState(); + + _lifecyleListener = AppLifecycleListener( + onResume: _onLifecycleResume, + ); } @override @@ -91,6 +97,7 @@ class _MessageListPageState extends State with RouteAware { ApplicationLog.debug('MessageListPage::dispose'); Navi.modalRouteObserver.unsubscribe(this); _pagingController.dispose(); + _lifecyleListener.dispose(); super.dispose(); } @@ -105,6 +112,11 @@ class _MessageListPageState extends State with RouteAware { _backgroundRefresh(false); } + void _onLifecycleResume() { + ApplicationLog.debug('[MessageList::_onLifecycleResume] --> (will background-refresh)'); + _backgroundRefresh(false); + } + Future _fetchPage(String thisPageToken) async { final acc = Provider.of(context, listen: false);