diff --git a/lib/api/model/model.dart b/lib/api/model/model.dart index fad8ddc5bc..e1d91fbce1 100644 --- a/lib/api/model/model.dart +++ b/lib/api/model/model.dart @@ -690,7 +690,7 @@ extension type const TopicName(String _value) { /// so that UI code can identify when it needs to represent the topic /// specially in the way prescribed for "general chat". // TODO(#1250) carry out that plan - String get displayName => _value; + String? get displayName => _value.isEmpty ? null : _value; /// The key to use for "same topic as" comparisons. String canonicalize() => apiName.toLowerCase(); diff --git a/lib/model/autocomplete.dart b/lib/model/autocomplete.dart index d860c487a6..2f14ee8d71 100644 --- a/lib/model/autocomplete.dart +++ b/lib/model/autocomplete.dart @@ -942,7 +942,6 @@ class TopicAutocompleteQuery extends AutocompleteQuery { bool testTopic(PerAccountStore store, TopicName topic) { // TODO(#881): Sort by match relevance, like web does. - // ignore: unnecessary_null_comparison // null topic names soon to be enabled if (topic.displayName == null) { return store.realmEmptyTopicDisplayName.toLowerCase() .contains(raw.toLowerCase()); @@ -950,7 +949,6 @@ class TopicAutocompleteQuery extends AutocompleteQuery { // This checks for inequality because there is nothing to autocomplete to // when `raw` already matches the topic exactly. return topic.displayName != raw - // ignore: unnecessary_non_null_assertion // null topic names soon to be enabled && topic.displayName!.toLowerCase().contains(raw.toLowerCase()); } diff --git a/lib/widgets/autocomplete.dart b/lib/widgets/autocomplete.dart index 97c17808b9..619364f5d1 100644 --- a/lib/widgets/autocomplete.dart +++ b/lib/widgets/autocomplete.dart @@ -366,13 +366,11 @@ class TopicAutocomplete extends AutocompleteField { } void setTopic(TopicName newTopic) { - // ignore: dead_null_aware_expression // null topic names soon to be enabled value = TextEditingValue(text: newTopic.displayName ?? ''); } } diff --git a/lib/widgets/inbox.dart b/lib/widgets/inbox.dart index aa1def389c..e8b41fe9b5 100644 --- a/lib/widgets/inbox.dart +++ b/lib/widgets/inbox.dart @@ -537,7 +537,6 @@ class _TopicItem extends StatelessWidget { child: Text( style: TextStyle( fontSize: 17, - // ignore: unnecessary_null_comparison // null topic names soon to be enabled fontStyle: topic.displayName == null ? FontStyle.italic : null, height: (20 / 17), // TODO(design) check if this is the right variable @@ -545,7 +544,6 @@ class _TopicItem extends StatelessWidget { ), maxLines: 2, overflow: TextOverflow.ellipsis, - // ignore: dead_null_aware_expression // null topic names soon to be enabled topic.displayName ?? store.realmEmptyTopicDisplayName))), const SizedBox(width: 12), if (hasMention) const _IconMarker(icon: ZulipIcons.at_sign), diff --git a/lib/widgets/message_list.dart b/lib/widgets/message_list.dart index de1da3a8d0..f1fb646e29 100644 --- a/lib/widgets/message_list.dart +++ b/lib/widgets/message_list.dart @@ -366,10 +366,8 @@ class MessageListAppBarTitle extends StatelessWidget { return Row( mainAxisSize: MainAxisSize.min, children: [ - // ignore: dead_null_aware_expression // null topic names soon to be enabled Flexible(child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, style: TextStyle( fontSize: 13, - // ignore: unnecessary_null_comparison // null topic names soon to be enabled fontStyle: topic.displayName == null ? FontStyle.italic : null, ).merge(weightVariableTextStyle(context)))), if (icon != null) @@ -1120,13 +1118,11 @@ class StreamMessageRecipientHeader extends StatelessWidget { child: Row( children: [ Flexible( - // ignore: dead_null_aware_expression // null topic names soon to be enabled child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, // TODO: Give a way to see the whole topic (maybe a // long-press interaction?) overflow: TextOverflow.ellipsis, style: recipientHeaderTextStyle(context).copyWith( - // ignore: unnecessary_null_comparison // null topic names soon to be enabled fontStyle: topic.displayName == null ? FontStyle.italic : null, ))), const SizedBox(width: 4), diff --git a/test/api/model/model_checks.dart b/test/api/model/model_checks.dart index 8b39b1ad57..747b2e1233 100644 --- a/test/api/model/model_checks.dart +++ b/test/api/model/model_checks.dart @@ -48,7 +48,7 @@ extension MessageChecks on Subject { extension TopicNameChecks on Subject { Subject get apiName => has((x) => x.apiName, 'apiName'); - Subject get displayName => has((x) => x.displayName, 'displayName'); + Subject get displayName => has((x) => x.displayName, 'displayName'); } extension StreamMessageChecks on Subject { diff --git a/test/widgets/action_sheet_test.dart b/test/widgets/action_sheet_test.dart index 7da94cfd36..7ae806d442 100644 --- a/test/widgets/action_sheet_test.dart +++ b/test/widgets/action_sheet_test.dart @@ -209,7 +209,7 @@ void main() { await tester.longPress(find.descendant( of: find.byType(RecipientHeader), - matching: find.text(effectiveMessage.topic.displayName))); + matching: find.text(effectiveMessage.topic.displayName!))); // sheet appears onscreen; default duration of bottom-sheet enter animation await tester.pump(const Duration(milliseconds: 250)); } diff --git a/test/widgets/autocomplete_test.dart b/test/widgets/autocomplete_test.dart index 35e8a52cb3..9de8c19ff9 100644 --- a/test/widgets/autocomplete_test.dart +++ b/test/widgets/autocomplete_test.dart @@ -355,7 +355,7 @@ void main() { await tester.tap(find.text('Topic three')); await tester.pumpAndSettle(); check(tester.widget(topicInputFinder).controller!.text) - .equals(topic3.name.displayName); + .equals(topic3.name.displayName!); check(find.text('Topic one' )).findsNothing(); check(find.text('Topic two' )).findsNothing(); check(find.text('Topic three')).findsOne(); // shown in `_TopicInput` once @@ -412,7 +412,7 @@ void main() { await tester.pumpAndSettle(); check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne(); - }, skip: true); // null topic names soon to be enabled + }); testWidgets('match general chat in autocomplete', (tester) async { final topic = eg.getStreamTopicsEntry(name: ''); @@ -424,7 +424,7 @@ void main() { await tester.pumpAndSettle(); check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne(); - }, skip: true); // null topic names soon to be enabled + }); testWidgets('autocomplete to general chat sets topic to empty string', (tester) async { final topic = eg.getStreamTopicsEntry(name: ''); @@ -439,6 +439,6 @@ void main() { await tester.tap(find.text(eg.defaultRealmEmptyTopicDisplayName)); await tester.pump(Duration.zero); check(controller.value).text.equals(''); - }, skip: true); // null topic names soon to be enabled + }); }); } diff --git a/test/widgets/inbox_test.dart b/test/widgets/inbox_test.dart index b5bf9d0ece..c790e63d15 100644 --- a/test/widgets/inbox_test.dart +++ b/test/widgets/inbox_test.dart @@ -315,7 +315,7 @@ void main() { unreadMessages: [eg.streamMessage(stream: channel, topic: '')]); check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne(); - }, skip: true); // null topic names soon to be enabled + }); group('topic visibility', () { final channel = eg.stream(); diff --git a/test/widgets/message_list_test.dart b/test/widgets/message_list_test.dart index 135db970bd..4106bc42fb 100644 --- a/test/widgets/message_list_test.dart +++ b/test/widgets/message_list_test.dart @@ -862,7 +862,7 @@ void main() { await tester.pump(); check(findInMessageList('stream name')).single; check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single; - }, skip: true); // null topic names soon to be enabled + }); testWidgets('show general chat for empty topics without channel name', (tester) async { await setupMessageListPage(tester, @@ -871,7 +871,7 @@ void main() { await tester.pump(); check(findInMessageList('stream name')).isEmpty(); check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single; - }, skip: true); // null topic names soon to be enabled + }); testWidgets('show topic visibility icon when followed', (tester) async { await setupMessageListPage(tester,