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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conceptually I think this should be private. It is convenient to use it in checkInvariants; but then let's mark it @visibleForTesting.


/// 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this feels to me like it belongs after the lifecycle methods, next to _messageVisible and friends

CombinedFeedNarrow()
|| ChannelNarrow()
|| TopicNarrow()
|| DmNarrow() => false,
MentionsNarrow()
|| StarredMessagesNarrow() => true,
Comment on lines +622 to +628
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic should get some dartdoc, to guide people adding cases to it in the future.

Comment on lines +622 to +628
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to have a test that would fail if this started being all true or all false. Maybe a quick test case for a channel narrow, and another for the mentions narrow, showing different results with the same two messages.

};

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