Skip to content

Commit 75a10e7

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

13 files changed

+14
-28
lines changed

lib/api/model/model.dart

+1-1
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

-2
Original file line numberDiff line numberDiff line change
@@ -942,14 +942,12 @@ 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
// Skip this option if it matches the query exactly.
951950
return topic.displayName != raw
952-
// ignore: unnecessary_non_null_assertion // null topic names soon to be enabled
953951
&& topic.displayName!.toLowerCase().contains(raw.toLowerCase());
954952
}
955953

lib/widgets/action_sheet.dart

-1
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

-2
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,11 @@ class TopicAutocomplete extends AutocompleteField<TopicAutocompleteQuery, TopicA
368368
@override
369369
Widget buildItem(BuildContext context, int index, TopicAutocompleteResult option) {
370370
final Widget child;
371-
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
372371
if (option.topic.displayName == null) {
373372
final store = PerAccountStoreWidget.of(context);
374373
child = Text(store.realmEmptyTopicDisplayName,
375374
style: const TextStyle(fontStyle: FontStyle.italic));
376375
} else {
377-
// ignore: unnecessary_non_null_assertion // null topic names soon to be enabled
378376
child = Text(option.topic.displayName!);
379377
}
380378

lib/widgets/compose_box.dart

-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ class ComposeTopicController extends ComposeController<TopicValidationError> {
243243
}
244244

245245
void setTopic(TopicName newTopic) {
246-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
247246
value = TextEditingValue(text: newTopic.displayName ?? '');
248247
}
249248
}
@@ -812,7 +811,6 @@ class _FixedDestinationContentInput extends StatelessWidget {
812811
// Zulip expresses channels and topics, not any normal English punctuation,
813812
// so don't make sense to translate. See:
814813
// https://github.com/zulip/zulip-flutter/pull/1148#discussion_r1941990585
815-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
816814
'#$streamName > ${topic.displayName ?? store.realmEmptyTopicDisplayName}');
817815

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

lib/widgets/inbox.dart

-2
Original file line numberDiff line numberDiff line change
@@ -531,15 +531,13 @@ class _TopicItem extends StatelessWidget {
531531
child: Text(
532532
style: TextStyle(
533533
fontSize: 17,
534-
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
535534
fontStyle: topic.displayName == null ? FontStyle.italic : null,
536535
height: (20 / 17),
537536
// TODO(design) check if this is the right variable
538537
color: designVariables.labelMenuButton,
539538
),
540539
maxLines: 2,
541540
overflow: TextOverflow.ellipsis,
542-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
543541
topic.displayName ?? store.realmEmptyTopicDisplayName))),
544542
const SizedBox(width: 12),
545543
if (hasMention) const _IconMarker(icon: ZulipIcons.at_sign),

lib/widgets/message_list.dart

-4
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)
@@ -1122,13 +1120,11 @@ class StreamMessageRecipientHeader extends StatelessWidget {
11221120
child: Row(
11231121
children: [
11241122
Flexible(
1125-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
11261123
child: Text(topic.displayName ?? store.realmEmptyTopicDisplayName,
11271124
// TODO: Give a way to see the whole topic (maybe a
11281125
// long-press interaction?)
11291126
overflow: TextOverflow.ellipsis,
11301127
style: recipientHeaderTextStyle(context).copyWith(
1131-
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
11321128
fontStyle: topic.displayName == null ? FontStyle.italic : null,
11331129
))),
11341130
const SizedBox(width: 4),

test/api/model/model_checks.dart

+1-1
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

+2-3
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

+4-4
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

+3-3
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ void main() {
549549
mandatoryTopics: false);
550550
checkComposeBoxHintTexts(tester, contentHintText:
551551
'Message #${channel.name} > ${eg.defaultRealmEmptyTopicDisplayName}');
552-
}, skip: true); // null topic names soon to be enabled
552+
});
553553
});
554554

555555
testWidgets('to DmNarrow with self', (tester) async {
@@ -861,7 +861,7 @@ void main() {
861861
..method.equals('POST')
862862
..url.path.equals('/api/v1/messages')
863863
..bodyFields['topic'].equals('');
864-
}, skip: true); // null topic names soon to be enabled
864+
});
865865

866866
testWidgets('legacy: empty topic -> "(no topic)"', (tester) async {
867867
await setupAndTapSend(tester,
@@ -886,7 +886,7 @@ void main() {
886886
topicInputText: eg.defaultRealmEmptyTopicDisplayName,
887887
mandatoryTopics: true);
888888
checkMessageNotSent(tester);
889-
}, skip: true); // null topic names soon to be enabled
889+
});
890890

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

test/widgets/inbox_test.dart

+1-1
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

+2-2
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)