Skip to content

Commit 87df780

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 619eb24 commit 87df780

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
@@ -946,7 +946,7 @@ class _TypingStatusWidgetState extends State<TypingStatusWidget> with PerAccount
946946
final store = PerAccountStoreWidget.of(context);
947947
final zulipLocalizations = ZulipLocalizations.of(context);
948948
final typistIds = model!.typistIdsInNarrow(narrow);
949-
if (typistIds.isEmpty) return const SizedBox();
949+
if (typistIds == null) return const SizedBox();
950950
final text = switch (typistIds.length) {
951951
1 => zulipLocalizations.onePersonTyping(
952952
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)