1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2024-12-25 12:28:50 +00:00

Update the number of unread conversations

This commit is contained in:
Pierre HUBERT 2020-05-08 15:42:44 +02:00
parent 5fb845732f
commit a64a192d27

View File

@ -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<UnreadConversationsScreen> {
class _UnreadConversationsScreenState
extends SafeState<UnreadConversationsScreen> {
UnreadConversationsList _list;
UsersList _users;
final _key = GlobalKey<AsyncScreenWidgetState>();
Future<void> _refresh() async {
_list = await ConversationsHelper.getListUnread();
_users = await UsersHelper().getListWithThrow(_list.usersID);
}
@override
void initState() {
super.initState();
listen<NewNumberUnreadConversations>((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!"),