recalculate unrad count incases some not read
This commit is contained in:
parent
1a9f0763d7
commit
8a9ee402bf
|
@ -120,6 +120,10 @@ class ProfileInfoState extends ChangeNotifier {
|
|||
notifyListeners();
|
||||
}
|
||||
|
||||
void recountUnread() {
|
||||
this._unreadMessages = _contacts.contacts.fold(0, (i, c) => i + c.unreadMessages);
|
||||
}
|
||||
|
||||
// Remove a contact from a list. Currently only used when rejecting a group invitation.
|
||||
// Eventually will also be used for other removals.
|
||||
void removeContact(String handle) {
|
||||
|
@ -168,6 +172,7 @@ class ProfileInfoState extends ChangeNotifier {
|
|||
lastMessageTime: DateTime.fromMillisecondsSinceEpoch(1000 * int.parse(contact["lastMsgTime"])),
|
||||
));
|
||||
}
|
||||
unreadMessages += int.parse(contact["numUnread"]);
|
||||
});
|
||||
}
|
||||
this._contacts.resort();
|
||||
|
|
|
@ -81,6 +81,7 @@ class _ContactsViewState extends State<ContactsView> {
|
|||
icon: Icon(Icons.arrow_back),
|
||||
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
|
||||
onPressed: () {
|
||||
Provider.of<ProfileInfoState>(context, listen: false).recountUnread();
|
||||
Provider.of<AppState>(context, listen: false).selectedProfile = "";
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:cwtch/models/appstate.dart';
|
||||
import 'package:cwtch/models/contactlist.dart';
|
||||
import 'package:cwtch/models/profile.dart';
|
||||
import 'package:cwtch/models/profilelist.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:cwtch/views/addeditprofileview.dart';
|
||||
|
@ -83,7 +84,6 @@ class _ProfileRowState extends State<ProfileRow> {
|
|||
}
|
||||
|
||||
void _pushContactList(ProfileInfoState profile, bool isLandscape) {
|
||||
Provider.of<ProfileInfoState>(context, listen: false).unreadMessages = 0;
|
||||
Navigator.of(context).push(
|
||||
MaterialPageRoute<void>(
|
||||
settings: RouteSettings(name: "conversations"),
|
||||
|
|
Loading…
Reference in New Issue