mirror of
https://gitlab.com/comunic/comunicmobile
synced 2024-11-22 21:09:21 +00:00
Update the number of unread conversations
This commit is contained in:
parent
5fb845732f
commit
a64a192d27
@ -1,9 +1,11 @@
|
|||||||
import 'package:comunic/helpers/conversations_helper.dart';
|
import 'package:comunic/helpers/conversations_helper.dart';
|
||||||
|
import 'package:comunic/helpers/events_helper.dart';
|
||||||
import 'package:comunic/helpers/users_helper.dart';
|
import 'package:comunic/helpers/users_helper.dart';
|
||||||
import 'package:comunic/lists/unread_conversations_list.dart';
|
import 'package:comunic/lists/unread_conversations_list.dart';
|
||||||
import 'package:comunic/lists/users_list.dart';
|
import 'package:comunic/lists/users_list.dart';
|
||||||
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
import 'package:comunic/ui/widgets/account_image_widget.dart';
|
||||||
import 'package:comunic/ui/widgets/async_screen_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/date_utils.dart';
|
||||||
import 'package:comunic/utils/intl_utils.dart';
|
import 'package:comunic/utils/intl_utils.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -18,18 +20,29 @@ class UnreadConversationsScreen extends StatefulWidget {
|
|||||||
_UnreadConversationsScreenState();
|
_UnreadConversationsScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _UnreadConversationsScreenState extends State<UnreadConversationsScreen> {
|
class _UnreadConversationsScreenState
|
||||||
|
extends SafeState<UnreadConversationsScreen> {
|
||||||
UnreadConversationsList _list;
|
UnreadConversationsList _list;
|
||||||
UsersList _users;
|
UsersList _users;
|
||||||
|
|
||||||
|
final _key = GlobalKey<AsyncScreenWidgetState>();
|
||||||
|
|
||||||
Future<void> _refresh() async {
|
Future<void> _refresh() async {
|
||||||
_list = await ConversationsHelper.getListUnread();
|
_list = await ConversationsHelper.getListUnread();
|
||||||
_users = await UsersHelper().getListWithThrow(_list.usersID);
|
_users = await UsersHelper().getListWithThrow(_list.usersID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
listen<NewNumberUnreadConversations>((e) => _key.currentState.refresh());
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return AsyncScreenWidget(
|
return AsyncScreenWidget(
|
||||||
|
key: _key,
|
||||||
onReload: _refresh,
|
onReload: _refresh,
|
||||||
onBuild: _buildList,
|
onBuild: _buildList,
|
||||||
errorMessage: tr("Could not load the list of unread conversations!"),
|
errorMessage: tr("Could not load the list of unread conversations!"),
|
||||||
|
Loading…
Reference in New Issue
Block a user