Skip to content

Commit e851fc6

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

13 files changed

+15
-29
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/action_sheet.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ void showTopicActionSheet(BuildContext context, {
253253
// TODO: check for other cases that may disallow this action (e.g.: time
254254
// limit for editing topics).
255255
final allowResolveUnresolve =
256-
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
257256
message == null || message.topic.displayName != null;
258257
if (someMessageIdInTopic != null && allowResolveUnresolve) {
259258
optionButtons.add(ResolveUnresolveButton(pageContext: pageContext,

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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ class ComposeTopicController extends ComposeController<TopicValidationError> {
226226
}
227227

228228
void setTopic(TopicName newTopic) {
229-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
230229
value = TextEditingValue(text: newTopic.displayName ?? '');
231230
}
232231
}
@@ -698,7 +697,6 @@ class _FixedDestinationContentInput extends StatelessWidget {
698697
// Zulip expresses channels and topics, not any normal English punctuation,
699698
// so don't make sense to translate. See:
700699
// https://github.com/zulip/zulip-flutter/pull/1148#discussion_r1941990585
701-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
702700
'#$streamName > ${topic.displayName ?? store.realmEmptyTopicDisplayName}');
703701

704702
case DmNarrow(otherRecipientIds: []): // The self-1:1 thread.

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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ void main() {
185185

186186
final topicRow = find.descendant(
187187
of: find.byType(ZulipAppBar),
188-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
189188
matching: find.text(topicName.displayName ?? eg.defaultRealmEmptyTopicDisplayName));
190189
await tester.longPress(topicRow);
191190
// sheet appears onscreen; default duration of bottom-sheet enter animation
@@ -206,7 +205,7 @@ void main() {
206205

207206
await tester.longPress(find.descendant(
208207
of: find.byType(RecipientHeader),
209-
matching: find.text(effectiveMessage.topic.displayName)));
208+
matching: find.text(effectiveMessage.topic.displayName!)));
210209
// sheet appears onscreen; default duration of bottom-sheet enter animation
211210
await tester.pump(const Duration(milliseconds: 250));
212211
}
@@ -270,7 +269,7 @@ void main() {
270269
messages: [message]);
271270
check(findButtonForLabel('Mark as resolved')).findsNothing();
272271
check(findButtonForLabel('Mark as unresolved')).findsNothing();
273-
}, skip: true); // null topic names soon to be enabled
272+
});
274273

275274
testWidgets('show from recipient header', (tester) async {
276275
await prepare();

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/compose_box_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void main() {
366366
checkComposeBoxHintTexts(tester,
367367
topicHintText: 'Topic',
368368
contentHintText: 'Message #${channel.name} > ${eg.defaultRealmEmptyTopicDisplayName}');
369-
}, skip: true); // null topic names soon to be enabled
369+
});
370370

371371
testWidgets('legacy: with empty topic', (tester) async {
372372
await prepare(tester, narrow: ChannelNarrow(channel.streamId),
@@ -434,7 +434,7 @@ void main() {
434434
mandatoryTopics: false);
435435
checkComposeBoxHintTexts(tester, contentHintText:
436436
'Message #${channel.name} > ${eg.defaultRealmEmptyTopicDisplayName}');
437-
}, skip: true); // null topic names soon to be enabled
437+
});
438438
});
439439

440440
testWidgets('to DmNarrow with self', (tester) async {
@@ -746,7 +746,7 @@ void main() {
746746
..method.equals('POST')
747747
..url.path.equals('/api/v1/messages')
748748
..bodyFields['topic'].equals('');
749-
}, skip: true); // null topic names soon to be enabled
749+
});
750750

751751
testWidgets('legacy: empty topic -> "(no topic)"', (tester) async {
752752
await setupAndTapSend(tester,
@@ -771,7 +771,7 @@ void main() {
771771
topicInputText: eg.defaultRealmEmptyTopicDisplayName,
772772
mandatoryTopics: true);
773773
checkMessageNotSent(tester);
774-
}, skip: true); // null topic names soon to be enabled
774+
});
775775

776776
testWidgets('if topics are mandatory, reject "(no topic)"', (tester) async {
777777
await setupAndTapSend(tester,

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)