Skip to content

Commit e70bf9d

Browse files
committed
message [nfc]: Make helper methods _notifyMessageListViews{,ForOneMessage}
1 parent 361fd27 commit e70bf9d

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

lib/model/message.dart

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ class MessageStoreImpl extends PerAccountStoreBase with MessageStore {
6363
assert(removed);
6464
}
6565

66+
void _notifyMessageListViewsForOneMessage(int messageId) {
67+
for (final view in _messageListViews) {
68+
view.notifyListenersIfMessagePresent(messageId);
69+
}
70+
}
71+
72+
void _notifyMessageListViews(Iterable<int> messageIds) {
73+
for (final view in _messageListViews) {
74+
view.notifyListenersIfAnyMessagePresent(messageIds);
75+
}
76+
}
77+
6678
void reassemble() {
6779
for (final view in _messageListViews) {
6880
view.reassemble();
@@ -142,9 +154,7 @@ class MessageStoreImpl extends PerAccountStoreBase with MessageStore {
142154
_handleUpdateMessageEventTimestamp(event);
143155
_handleUpdateMessageEventContent(event);
144156
_handleUpdateMessageEventMove(event);
145-
for (final view in _messageListViews) {
146-
view.notifyListenersIfAnyMessagePresent(event.messageIds);
147-
}
157+
_notifyMessageListViews(event.messageIds);
148158
}
149159

150160
void _handleUpdateMessageEventTimestamp(UpdateMessageEvent event) {
@@ -268,17 +278,15 @@ class MessageStoreImpl extends PerAccountStoreBase with MessageStore {
268278
: message.flags.remove(event.flag);
269279
}
270280
if (anyMessageFound) {
271-
for (final view in _messageListViews) {
272-
view.notifyListenersIfAnyMessagePresent(event.messages);
273-
// TODO(#818): Support MentionsNarrow live-updates when handling
274-
// @-mention flags.
275-
276-
// To make it easier to re-star a message, we opt-out from supporting
277-
// live-updates when starred flag is removed.
278-
//
279-
// TODO: Support StarredMessagesNarrow live-updates when starred flag
280-
// is added.
281-
}
281+
// TODO(#818): Support MentionsNarrow live-updates when handling
282+
// @-mention flags.
283+
284+
// To make it easier to re-star a message, we opt-out from supporting
285+
// live-updates when starred flag is removed.
286+
//
287+
// TODO: Support StarredMessagesNarrow live-updates when starred flag
288+
// is added.
289+
_notifyMessageListViews(event.messages);
282290
}
283291
}
284292
}
@@ -305,10 +313,7 @@ class MessageStoreImpl extends PerAccountStoreBase with MessageStore {
305313
userId: event.userId,
306314
);
307315
}
308-
309-
for (final view in _messageListViews) {
310-
view.notifyListenersIfMessagePresent(event.messageId);
311-
}
316+
_notifyMessageListViewsForOneMessage(event.messageId);
312317
}
313318

314319
void handleSubmessageEvent(SubmessageEvent event) {

0 commit comments

Comments
 (0)