@@ -41,13 +41,15 @@ class Unreads extends ChangeNotifier {
41
41
required ChannelStore channelStore,
42
42
}) {
43
43
final streams = < int , Map <String , QueueList <int >>> {};
44
+ final topicMapper = < String , String > {};
44
45
final dms = < DmNarrow , QueueList <int >> {};
45
46
final mentions = Set .of (initial.mentions);
46
47
47
48
for (final unreadChannelSnapshot in initial.channels) {
48
49
final streamId = unreadChannelSnapshot.streamId;
49
50
final topic = unreadChannelSnapshot.topic;
50
- (streams[streamId] ?? = {})[topic] = QueueList .from (unreadChannelSnapshot.unreadMessageIds);
51
+ topicMapper[topic.toLowerCase ()] = topic;
52
+ (streams[streamId] ?? = {})[topic.toLowerCase ()] = QueueList .from (unreadChannelSnapshot.unreadMessageIds);
51
53
}
52
54
53
55
for (final unreadDmSnapshot in initial.dms) {
@@ -64,6 +66,7 @@ class Unreads extends ChangeNotifier {
64
66
return Unreads ._(
65
67
channelStore: channelStore,
66
68
streams: streams,
69
+ topicMapper: topicMapper,
67
70
dms: dms,
68
71
mentions: mentions,
69
72
oldUnreadsMissing: initial.oldUnreadsMissing,
@@ -74,6 +77,7 @@ class Unreads extends ChangeNotifier {
74
77
Unreads ._({
75
78
required this .channelStore,
76
79
required this .streams,
80
+ required this .topicMapper,
77
81
required this .dms,
78
82
required this .mentions,
79
83
required this .oldUnreadsMissing,
@@ -88,6 +92,9 @@ class Unreads extends ChangeNotifier {
88
92
/// Unread stream messages, as: stream ID → topic → message IDs (sorted).
89
93
final Map <int , Map <String , QueueList <int >>> streams;
90
94
95
+ // Maps lowercase topic names for lookup to one of the variants of the topic (case preserving).
96
+ final Map <String , String > topicMapper;
97
+
91
98
/// Unread DM messages, as: DM narrow → message IDs (sorted).
92
99
final Map <DmNarrow , QueueList <int >> dms;
93
100
@@ -368,7 +375,7 @@ class Unreads extends ChangeNotifier {
368
375
switch (detail.type) {
369
376
case MessageType .stream:
370
377
final topics = (newlyUnreadInStreams[detail.streamId! ] ?? = {});
371
- final messageIds = (topics[detail.topic! ] ?? = QueueList ());
378
+ final messageIds = (topics[detail.topic! . toLowerCase () ] ?? = QueueList ());
372
379
messageIds.add (messageId);
373
380
case MessageType .direct:
374
381
final narrow = DmNarrow .ofUpdateMessageFlagsMessageDetail (selfUserId: selfUserId,
@@ -437,7 +444,8 @@ class Unreads extends ChangeNotifier {
437
444
}
438
445
439
446
void _addLastInStreamTopic (int messageId, int streamId, String topic) {
440
- ((streams[streamId] ?? = {})[topic] ?? = QueueList ()).addLast (messageId);
447
+ topicMapper[topic.toLowerCase ()] = topic;
448
+ ((streams[streamId] ?? = {})[topic.toLowerCase ()] ?? = QueueList ()).addLast (messageId);
441
449
}
442
450
443
451
// [messageIds] must be sorted ascending and without duplicates.
0 commit comments