Skip to content

msglist: Show recipient headers on all messages, in Mentions / Starred #1638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/model/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ enum FetchingStatus {
///
/// This comprises much of the guts of [MessageListView].
mixin _MessageSequence {
bool get oneMessagePerBlock;

/// A sequence number for invalidating stale fetches.
int generation = 0;

Expand Down Expand Up @@ -435,7 +437,11 @@ mixin _MessageSequence {
required MessageListMessageBaseItem Function(bool canShareSender) buildItem,
}) {
final bool canShareSender;
if (prevMessage == null || !haveSameRecipient(prevMessage, message)) {
if (
prevMessage == null
|| oneMessagePerBlock
|| !haveSameRecipient(prevMessage, message)
) {
items.add(MessageListRecipientHeaderItem(message));
canShareSender = false;
} else {
Expand Down Expand Up @@ -613,6 +619,15 @@ class MessageListView with ChangeNotifier, _MessageSequence {
Anchor get anchor => _anchor;
Anchor _anchor;

@override bool get oneMessagePerBlock => switch (narrow) {
CombinedFeedNarrow()
|| ChannelNarrow()
|| TopicNarrow()
|| DmNarrow() => false,
MentionsNarrow()
|| StarredMessagesNarrow() => true,
};

void _register() {
store.registerMessageList(this);
}
Expand Down
1 change: 1 addition & 0 deletions test/model/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3011,6 +3011,7 @@ void checkInvariants(MessageListView model) {
for (int j = 0; j < allMessages.length; j++) {
bool forcedShowSender = false;
if (j == 0
|| model.oneMessagePerBlock
|| !haveSameRecipient(allMessages[j-1], allMessages[j])) {
check(model.items[i++]).isA<MessageListRecipientHeaderItem>()
.message.identicalTo(allMessages[j]);
Expand Down