Skip to content

Commit 447f9f4

Browse files
committed
do not merge; api: Make displayName nullable
Signed-off-by: Zixuan James Li <[email protected]>
1 parent d2f88aa commit 447f9f4

11 files changed

+10
-21
lines changed

lib/api/model/model.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ extension type const TopicName(String _value) {
690690
/// so that UI code can identify when it needs to represent the topic
691691
/// specially in the way prescribed for "general chat".
692692
// TODO(#1250) carry out that plan
693-
String get displayName => _value;
693+
String? get displayName => _value.isEmpty ? null : _value;
694694

695695
/// The key to use for "same topic as" comparisons.
696696
String canonicalize() => apiName.toLowerCase();

lib/model/autocomplete.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,15 +942,13 @@ class TopicAutocompleteQuery extends AutocompleteQuery {
942942
bool testTopic(PerAccountStore store, TopicName topic) {
943943
// TODO(#881): Sort by match relevance, like web does.
944944

945-
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
946945
if (topic.displayName == null) {
947946
return store.realmEmptyTopicDisplayName.toLowerCase()
948947
.contains(raw.toLowerCase());
949948
}
950949
// This checks for inequality because there is nothing to autocomplete to
951950
// when `raw` already matches the topic exactly.
952951
return topic.displayName != raw
953-
// ignore: unnecessary_non_null_assertion // null topic names soon to be enabled
954952
&& topic.displayName!.toLowerCase().contains(raw.toLowerCase());
955953
}
956954

lib/widgets/autocomplete.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,11 @@ class TopicAutocomplete extends AutocompleteField<TopicAutocompleteQuery, TopicA
366366
@override
367367
Widget buildItem(BuildContext context, int index, TopicAutocompleteResult option) {
368368
final Widget child;
369-
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
370369
if (option.topic.displayName == null) {
371370
final store = PerAccountStoreWidget.of(context);
372371
child = Text(store.realmEmptyTopicDisplayName,
373372
style: const TextStyle(fontStyle: FontStyle.italic));
374373
} else {
375-
// ignore: unnecessary_non_null_assertion // null topic names soon to be enabled
376374
child = Text(option.topic.displayName!);
377375
}
378376

lib/widgets/compose_box.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ class ComposeTopicController extends ComposeController<TopicValidationError> {
182182
}
183183

184184
void setTopic(TopicName newTopic) {
185-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
186185
value = TextEditingValue(text: newTopic.displayName ?? '');
187186
}
188187
}

lib/widgets/inbox.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,15 +537,13 @@ class _TopicItem extends StatelessWidget {
537537
child: Text(
538538
style: TextStyle(
539539
fontSize: 17,
540-
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
541540
fontStyle: topic.displayName == null ? FontStyle.italic : null,
542541
height: (20 / 17),
543542
// TODO(design) check if this is the right variable
544543
color: designVariables.labelMenuButton,
545544
),
546545
maxLines: 2,
547546
overflow: TextOverflow.ellipsis,
548-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
549547
topic.displayName ?? store.realmEmptyTopicDisplayName))),
550548
const SizedBox(width: 12),
551549
if (hasMention) const _IconMarker(icon: ZulipIcons.at_sign),

lib/widgets/message_list.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,8 @@ class MessageListAppBarTitle extends StatelessWidget {
366366
return Row(
367367
mainAxisSize: MainAxisSize.min,
368368
children: [
369-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
370369
Flexible(child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName, style: TextStyle(
371370
fontSize: 13,
372-
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
373371
fontStyle: topic.displayName == null ? FontStyle.italic : null,
374372
).merge(weightVariableTextStyle(context)))),
375373
if (icon != null)
@@ -1123,13 +1121,11 @@ class StreamMessageRecipientHeader extends StatelessWidget {
11231121
child: Row(
11241122
children: [
11251123
Flexible(
1126-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
11271124
child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName,
11281125
// TODO: Give a way to see the whole topic (maybe a
11291126
// long-press interaction?)
11301127
overflow: TextOverflow.ellipsis,
11311128
style: recipientHeaderTextStyle(context).copyWith(
1132-
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
11331129
fontStyle: topic.displayName == null ? FontStyle.italic : null,
11341130
))),
11351131
const SizedBox(width: 4),

test/api/model/model_checks.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ extension MessageChecks on Subject<Message> {
4848

4949
extension TopicNameChecks on Subject<TopicName> {
5050
Subject<String> get apiName => has((x) => x.apiName, 'apiName');
51-
Subject<String> get displayName => has((x) => x.displayName, 'displayName');
51+
Subject<String?> get displayName => has((x) => x.displayName, 'displayName');
5252
}
5353

5454
extension StreamMessageChecks on Subject<StreamMessage> {

test/widgets/action_sheet_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void main() {
204204

205205
await tester.longPress(find.descendant(
206206
of: find.byType(RecipientHeader),
207-
matching: find.text(effectiveMessage.topic.displayName)));
207+
matching: find.text(effectiveMessage.topic.displayName!)));
208208
// sheet appears onscreen; default duration of bottom-sheet enter animation
209209
await tester.pump(const Duration(milliseconds: 250));
210210
}

test/widgets/autocomplete_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ void main() {
355355
await tester.tap(find.text('Topic three'));
356356
await tester.pumpAndSettle();
357357
check(tester.widget<TextField>(topicInputFinder).controller!.text)
358-
.equals(topic3.name.displayName);
358+
.equals(topic3.name.displayName!);
359359
check(find.text('Topic one' )).findsNothing();
360360
check(find.text('Topic two' )).findsNothing();
361361
check(find.text('Topic three')).findsOne(); // shown in `_TopicInput` once
@@ -412,7 +412,7 @@ void main() {
412412
await tester.pumpAndSettle();
413413

414414
check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne();
415-
}, skip: true); // null topic names soon to be enabled
415+
});
416416

417417
testWidgets('match general chat in autocomplete', (tester) async {
418418
final topic = eg.getStreamTopicsEntry(name: '');
@@ -424,7 +424,7 @@ void main() {
424424
await tester.pumpAndSettle();
425425

426426
check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne();
427-
}, skip: true); // null topic names soon to be enabled
427+
});
428428

429429
testWidgets('autocomplete to general chat sets topic to empty string', (tester) async {
430430
final topic = eg.getStreamTopicsEntry(name: '');
@@ -439,6 +439,6 @@ void main() {
439439
await tester.tap(find.text(eg.defaultRealmEmptyTopicDisplayName));
440440
await tester.pump(Duration.zero);
441441
check(controller.value).text.equals('');
442-
}, skip: true); // null topic names soon to be enabled
442+
});
443443
});
444444
}

test/widgets/inbox_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ void main() {
315315
unreadMessages: [eg.streamMessage(stream: channel, topic: '')]);
316316

317317
check(find.text(eg.defaultRealmEmptyTopicDisplayName)).findsOne();
318-
}, skip: true); // null topic names soon to be enabled
318+
});
319319

320320
group('topic visibility', () {
321321
final channel = eg.stream();

test/widgets/message_list_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ void main() {
943943
await tester.pump();
944944
check(findInMessageList('stream name')).single;
945945
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
946-
}, skip: true); // null topic names soon to be enabled
946+
});
947947

948948
testWidgets('show general chat for empty topics without channel name', (tester) async {
949949
await setupMessageListPage(tester,
@@ -952,7 +952,7 @@ void main() {
952952
await tester.pump();
953953
check(findInMessageList('stream name')).isEmpty();
954954
check(findInMessageList(eg.defaultRealmEmptyTopicDisplayName)).single;
955-
}, skip: true); // null topic names soon to be enabled
955+
});
956956

957957
testWidgets('show topic visibility icon when followed', (tester) async {
958958
await setupMessageListPage(tester,

0 commit comments

Comments
 (0)