Skip to content

Commit fcbbc9d

Browse files
shivanshsharma13gnprice
authored andcommitted
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 6070a7f commit fcbbc9d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/model/message_list.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ mixin _MessageSequence {
352352
bool haveSameRecipient(Message prevMessage, Message message) {
353353
if (prevMessage is StreamMessage && message is StreamMessage) {
354354
if (prevMessage.streamId != message.streamId) return false;
355-
if (prevMessage.topic != message.topic) return false;
355+
if (prevMessage.topic.toLowerCase() != message.topic.toLowerCase()) return false;
356356
} else if (prevMessage is DmMessage && message is DmMessage) {
357357
if (!_equalIdSequences(prevMessage.allRecipientIds, message.allRecipientIds)) {
358358
return false;

test/model/message_list_test.dart

+20
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,26 @@ void main() {
18031803
}
18041804
}
18051805
});
1806+
1807+
group('topics compared case-insensitively', () {
1808+
void doTest(String description, String topicA, String topicB, bool expected) {
1809+
test(description, () {
1810+
final stream = eg.stream();
1811+
final messageA = eg.streamMessage(stream: stream, topic: topicA);
1812+
final messageB = eg.streamMessage(stream: stream, topic: topicB);
1813+
check(haveSameRecipient(messageA, messageB)).equals(expected);
1814+
});
1815+
}
1816+
1817+
doTest('same case, all lower', 'abc', 'abc', true);
1818+
doTest('same case, all upper', 'ABC', 'ABC', true);
1819+
doTest('same case, mixed', 'AbC', 'AbC', true);
1820+
doTest('same non-cased chars', '嗎', '嗎', true);
1821+
doTest('different case', 'aBc', 'ABC', true);
1822+
doTest('different case, same diacritics', 'AbÇ', 'aBç', true);
1823+
doTest('same letters, different diacritics', 'ma', 'mǎ', false);
1824+
doTest('having different CJK characters', '嗎', '馬', false);
1825+
});
18061826
});
18071827

18081828
test('messagesSameDay', () {

0 commit comments

Comments
 (0)