Skip to content

Commit 712e75f

Browse files
msglist: Remove extra recipient header when topic changes case
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: #739
1 parent fb6291f commit 712e75f

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/model/message_list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ mixin _MessageSequence {
321321
bool haveSameRecipient(Message prevMessage, Message message) {
322322
if (prevMessage is StreamMessage && message is StreamMessage) {
323323
if (prevMessage.streamId != message.streamId) return false;
324-
if (prevMessage.topic != message.topic) return false;
324+
if (prevMessage.topic.toLowerCase() != message.topic.toLowerCase()) return false;
325325
} else if (prevMessage is DmMessage && message is DmMessage) {
326326
if (!_equalIdSequences(prevMessage.allRecipientIds, message.allRecipientIds)) {
327327
return false;

test/model/message_list_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,6 +1703,25 @@ void main() {
17031703
}
17041704
}
17051705
});
1706+
group('topics compared case-insensitively', () {
1707+
void doTest(String description, String topicA, String topicB, bool expected) {
1708+
test(description, () {
1709+
final stream = eg.stream();
1710+
final messageA = eg.streamMessage(stream: stream, topic: topicA);
1711+
final messageB = eg.streamMessage(stream: stream, topic: topicB);
1712+
check(haveSameRecipient(messageA, messageB)).equals(expected);
1713+
});
1714+
}
1715+
1716+
doTest('same case, all lower', 'abc', 'abc', true);
1717+
doTest('same case, all upper', 'ABC', 'ABC', true);
1718+
doTest('same case, mixed', 'AbC', 'AbC', true);
1719+
doTest('same non-cased chars', '嗎', '嗎', true);
1720+
doTest('different case', 'aBc', 'ABC', true);
1721+
doTest('different case, same diacritics', 'AbÇ', 'aBç', true);
1722+
doTest('same letters, different diacritics', 'ma', 'mǎ', false);
1723+
doTest('having different CJK characters', '嗎', '馬', false);
1724+
});
17061725
});
17071726

17081727
test('messagesSameDay', () {

0 commit comments

Comments
 (0)