@@ -32,8 +32,6 @@ import 'channel.dart';
32
32
/// unsubscribed streams and messages sent by muted users.
33
33
// TODO When [oldUnreadsMissing], if you load a message list with very old unreads,
34
34
// sync to those unreads, because the user has shown an interest in them.
35
- // TODO When loading a message list with stream messages, check all the stream
36
- // messages and refresh [mentions] (see [mentions] dartdoc).
37
35
class Unreads extends ChangeNotifier {
38
36
factory Unreads ({
39
37
required UnreadMessagesSnapshot initial,
@@ -103,7 +101,7 @@ class Unreads extends ChangeNotifier {
103
101
/// a) the message is edited at all ([UpdateMessageEvent] ),
104
102
/// assuming it still has a direct or wildcard mention after the edit, or
105
103
/// b) the message gains a direct @-mention ([UpdateMessageFlagsEvent] ), or
106
- /// c) TODO unimplemented: the user loads the message in the message list
104
+ /// c) the user loads the message in the message list
107
105
/// But otherwise, assume its unread state remains unknown to [mentions] .
108
106
///
109
107
/// [1] This item applies verbatim at Server 8.0+. For older servers, the
@@ -236,6 +234,19 @@ class Unreads extends ChangeNotifier {
236
234
notifyListeners ();
237
235
}
238
236
237
+ void onMessagesFetched (List <Message > messages) {
238
+ messages.forEach (_addMessageToMentionsIfMentioned);
239
+ }
240
+
241
+ void _addMessageToMentionsIfMentioned (Message message) {
242
+ if (message.flags.contains (MessageFlag .read)) return ;
243
+ if (! message.flags.contains (MessageFlag .mentioned)
244
+ && ! message.flags.contains (MessageFlag .wildcardMentioned)) return ;
245
+
246
+ mentions.add (message.id);
247
+ }
248
+
249
+
239
250
void handleUpdateMessageEvent (UpdateMessageEvent event) {
240
251
final messageId = event.messageId;
241
252
0 commit comments