Skip to content

Commit 1e5d2a3

Browse files
committed
api [nfc]: Factor out TopicName.canonicalize
1 parent 91c087c commit 1e5d2a3

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/api/model/model.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,9 @@ extension type const TopicName(String _value) implements String {
661661
/// The string this topic is identified by in the Zulip API.
662662
String get apiName => _value;
663663

664+
/// The key to use for "same topic as" comparisons.
665+
String canonicalize() => apiName.toLowerCase();
666+
664667
TopicName.fromJson(this._value);
665668

666669
String toJson() => apiName;

lib/model/message_list.dart

Lines changed: 1 addition & 1 deletion
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.toLowerCase() != message.topic.toLowerCase()) return false;
355+
if (prevMessage.topic.canonicalize() != message.topic.canonicalize()) return false;
356356
} else if (prevMessage is DmMessage && message is DmMessage) {
357357
if (!_equalIdSequences(prevMessage.allRecipientIds, message.allRecipientIds)) {
358358
return false;

0 commit comments

Comments
 (0)