Skip to content

Commit

Permalink
msglist: Remove extra recipient header when topic changes case
Browse files Browse the repository at this point in the history
This change makes the message list's topic headers case-insensitive
Messages with topics differing only in case (e.g., "missing string"
and "Missing string") will now share a single header. This aligns
the behavior with Zulip web and ensures a consistent user experience.

Fixes: zulip#739
  • Loading branch information
shivanshsharma13 committed Dec 18, 2024
1 parent fb6291f commit f2abecc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/model/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ mixin _MessageSequence {
bool haveSameRecipient(Message prevMessage, Message message) {
if (prevMessage is StreamMessage && message is StreamMessage) {
if (prevMessage.streamId != message.streamId) return false;
if (prevMessage.topic != message.topic) return false;
if (prevMessage.topic.toLowerCase() != message.topic.toLowerCase()) return false;
} else if (prevMessage is DmMessage && message is DmMessage) {
if (!_equalIdSequences(prevMessage.allRecipientIds, message.allRecipientIds)) {
return false;
Expand Down
19 changes: 19 additions & 0 deletions test/model/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,25 @@ void main() {
}
}
});
group('topics compared case-insensitively', () {
void doTest(String description, String topicA, String topicB, bool expected) {
test(description, () {
final stream = eg.stream();
final messageA = eg.streamMessage(stream: stream, topic: topicA);
final messageB = eg.streamMessage(stream: stream, topic: topicB);
check(haveSameRecipient(messageA, messageB)).equals(expected);
});
}

doTest('same case, all lower', 'abc', 'abc', true);
doTest('same case, all upper', 'ABC', 'ABC', true);
doTest('same case, mixed', 'AbC', 'AbC', true);
doTest('same non-cased chars', '嗎', '嗎', true);
doTest('different case', 'aBc', 'ABC', true);
doTest('different case, same diacritics', 'AbÇ', 'aBç', true);
doTest('same letters, different diacritics', 'ma', 'mǎ', false);
doTest('having different CJK characters', '嗎', '馬', false);
});
});

test('messagesSameDay', () {
Expand Down

0 comments on commit f2abecc

Please sign in to comment.