Skip to content

Commit 459e123

Browse files
committed
msglist [nfc]: Represent nobody-is-typing as null, not empty list
Just to skip the bit of extra work of creating new lists.
1 parent 53eb5a1 commit 459e123

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

lib/model/typing_status.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class TypingStatus extends PerAccountStoreBase with ChangeNotifier {
2121

2222
Iterable<SendableNarrow> get debugActiveNarrows => _timerMapsByNarrow.keys;
2323

24-
Iterable<int> typistIdsInNarrow(SendableNarrow narrow) =>
25-
_timerMapsByNarrow[narrow]?.keys ?? [];
24+
Iterable<int>? typistIdsInNarrow(SendableNarrow narrow) =>
25+
_timerMapsByNarrow[narrow]?.keys;
2626

2727
// Using SendableNarrow as the key covers the narrows
2828
// where typing notices are supported (topics and DMs).

lib/widgets/message_list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ class _TypingStatusWidgetState extends State<TypingStatusWidget> with PerAccount
10111011
final store = PerAccountStoreWidget.of(context);
10121012
final zulipLocalizations = ZulipLocalizations.of(context);
10131013
final typistIds = model!.typistIdsInNarrow(narrow);
1014-
if (typistIds.isEmpty) return const SizedBox();
1014+
if (typistIds == null) return const SizedBox();
10151015
final text = switch (typistIds.length) {
10161016
1 => zulipLocalizations.onePersonTyping(
10171017
store.userDisplayName(typistIds.first)),

test/model/typing_status_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void main() {
6565
}
6666

6767
void checkTypists(Map<SendableNarrow, List<User>> typistsByNarrow) {
68-
final actualTypistsByNarrow = <SendableNarrow, Iterable<int>>{};
68+
final actualTypistsByNarrow = <SendableNarrow, Iterable<int>?>{};
6969
for (final narrow in model.debugActiveNarrows) {
7070
actualTypistsByNarrow[narrow] = model.typistIdsInNarrow(narrow);
7171
}

0 commit comments

Comments
 (0)