Skip to content

Commit 1e49f63

Browse files
committed
msglist [nfc]: Pull out some asserts that also apply when haveSameRecipient
These invariants apply regardless of `haveSameRecipient`.
1 parent fc6bf8b commit 1e49f63

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/model/message_list.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,14 +451,15 @@ mixin _MessageSequence {
451451
items.add(MessageListRecipientHeaderItem(message));
452452
canShareSender = false;
453453
} else {
454+
assert(items.last is MessageListMessageBaseItem);
455+
final prevMessageItem = items.last as MessageListMessageBaseItem;
456+
assert(identical(prevMessageItem.message, prevMessage));
457+
assert(prevMessageItem.isLastInBlock);
458+
454459
if (oneMessagePerBlock || !haveSameRecipient(prevMessage, message)) {
455460
items.add(MessageListRecipientHeaderItem(message));
456461
canShareSender = false;
457462
} else {
458-
assert(items.last is MessageListMessageBaseItem);
459-
final prevMessageItem = items.last as MessageListMessageBaseItem;
460-
assert(identical(prevMessageItem.message, prevMessage));
461-
assert(prevMessageItem.isLastInBlock);
462463
prevMessageItem.isLastInBlock = false;
463464

464465
if (!messagesSameDay(prevMessageItem.message, message)) {

0 commit comments

Comments
 (0)