Skip to content

Commit 73c827c

Browse files
committed
recent_senders [nfc]: Rename some foosByBar that mean foosInBar
A map of "foos by bar" is a map where each key is a "bar", and each value is a "foo" -- the phrase can be read as an abbreviation of "foos indexed by bar" or "foos, where each foo is indexed by its respective bar". So in this function `messagesByUser` is accurately named because a key represents a user and a value represents some messages. But these other variables should be e.g. `topicsInStream`, not `topicsByStream`. That one isn't a map where the key is a stream and the value is a topic or topics; rather it's a collection of topics (and more data about them) which is the collection specifically of topics in the stream we're acting on.
1 parent d3d3774 commit 73c827c

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/model/recent_senders.dart

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,23 +78,23 @@ class RecentSenders {
7878
}
7979

8080
final DeleteMessageEvent(:streamId!, :topic!) = event;
81-
final sendersByStream = streamSenders[streamId];
82-
final topicsByStream = topicSenders[streamId];
83-
final sendersByTopic = topicsByStream?[topic];
81+
final sendersInStream = streamSenders[streamId];
82+
final topicsInStream = topicSenders[streamId];
83+
final sendersInTopic = topicsInStream?[topic];
8484
for (final entry in messagesByUser.entries) {
8585
final MapEntry(key: senderId, value: messages) = entry;
8686

87-
final messagesBySenderInStream = sendersByStream?[senderId];
88-
messagesBySenderInStream?.removeAll(messages);
89-
if (messagesBySenderInStream?.maxId == null) sendersByStream?.remove(senderId);
87+
final streamTracker = sendersInStream?[senderId];
88+
streamTracker?.removeAll(messages);
89+
if (streamTracker?.maxId == null) sendersInStream?.remove(senderId);
9090

91-
final messagesBySenderInTopic = sendersByTopic?[senderId];
92-
messagesBySenderInTopic?.removeAll(messages);
93-
if (messagesBySenderInTopic?.maxId == null) sendersByTopic?.remove(senderId);
91+
final topicTracker = sendersInTopic?[senderId];
92+
topicTracker?.removeAll(messages);
93+
if (topicTracker?.maxId == null) sendersInTopic?.remove(senderId);
9494
}
95-
if (sendersByStream?.isEmpty ?? false) streamSenders.remove(streamId);
96-
if (sendersByTopic?.isEmpty ?? false) topicsByStream?.remove(topic);
97-
if (topicsByStream?.isEmpty ?? false) topicSenders.remove(streamId);
95+
if (sendersInStream?.isEmpty ?? false) streamSenders.remove(streamId);
96+
if (sendersInTopic?.isEmpty ?? false) topicsInStream?.remove(topic);
97+
if (topicsInStream?.isEmpty ?? false) topicSenders.remove(streamId);
9898
}
9999
}
100100

0 commit comments

Comments
 (0)