From a64a192d2750c3196455c0f40fe519346cfb85cd Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 8 May 2020 15:42:44 +0200 Subject: [PATCH] Update the number of unread conversations --- lib/ui/screens/unread_conversations_screen.dart | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/ui/screens/unread_conversations_screen.dart b/lib/ui/screens/unread_conversations_screen.dart index e0ce2ab..d7a0b42 100644 --- a/lib/ui/screens/unread_conversations_screen.dart +++ b/lib/ui/screens/unread_conversations_screen.dart @@ -1,9 +1,11 @@ import 'package:comunic/helpers/conversations_helper.dart'; +import 'package:comunic/helpers/events_helper.dart'; import 'package:comunic/helpers/users_helper.dart'; import 'package:comunic/lists/unread_conversations_list.dart'; import 'package:comunic/lists/users_list.dart'; import 'package:comunic/ui/widgets/account_image_widget.dart'; import 'package:comunic/ui/widgets/async_screen_widget.dart'; +import 'package:comunic/ui/widgets/safe_state.dart'; import 'package:comunic/utils/date_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; import 'package:flutter/material.dart'; @@ -18,18 +20,29 @@ class UnreadConversationsScreen extends StatefulWidget { _UnreadConversationsScreenState(); } -class _UnreadConversationsScreenState extends State { +class _UnreadConversationsScreenState + extends SafeState { UnreadConversationsList _list; UsersList _users; + final _key = GlobalKey(); + Future _refresh() async { _list = await ConversationsHelper.getListUnread(); _users = await UsersHelper().getListWithThrow(_list.usersID); } + @override + void initState() { + super.initState(); + + listen((e) => _key.currentState.refresh()); + } + @override Widget build(BuildContext context) { return AsyncScreenWidget( + key: _key, onReload: _refresh, onBuild: _buildList, errorMessage: tr("Could not load the list of unread conversations!"),