Skip to content

Commit af66988

Browse files
committed
compose: Unskip test; show realmEmptyDisplayName in hint text
This logic was introduced in 769cc7d, which assumed that TopicName.displayName is `null` when the topic is empty. TopicName that came from the server are guaranteed to be non-empty, but here our code can construct an empty TopicName, breaking this assumption. Switch to using plain strings, and go back to constructing TopicName with empty topics once TopicName.displayName becomes nullable.
1 parent 2cf973f commit af66988

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/widgets/compose_box.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ class _StreamContentInputState extends State<_StreamContentInput> {
623623
}
624624

625625
/// The topic name to show in the hint text, or null to show no topic.
626-
TopicName? _hintTopic() {
626+
String? _hintTopicStr() {
627627
if (widget.controller.topic.isTopicVacuous) {
628628
if (widget.controller.topic.mandatory) {
629629
// The chosen topic can't be sent to, so don't show it.
@@ -638,7 +638,7 @@ class _StreamContentInputState extends State<_StreamContentInput> {
638638
}
639639
}
640640

641-
return TopicName(widget.controller.topic.textNormalized);
641+
return widget.controller.topic.textNormalized;
642642
}
643643

644644
@override
@@ -648,15 +648,15 @@ class _StreamContentInputState extends State<_StreamContentInput> {
648648

649649
final streamName = store.streams[widget.narrow.streamId]?.name
650650
?? zulipLocalizations.unknownChannelName;
651-
final hintTopic = _hintTopic();
652-
final hintDestination = hintTopic == null
651+
final hintTopicStr = _hintTopicStr();
652+
final hintDestination = hintTopicStr == null
653653
// No i18n of this use of "#" and ">" string; those are part of how
654654
// Zulip expresses channels and topics, not any normal English punctuation,
655655
// so don't make sense to translate. See:
656656
// https://github.com/zulip/zulip-flutter/pull/1148#discussion_r1941990585
657657
? '#$streamName'
658-
// ignore: dead_null_aware_expression // null topic names soon to be enabled
659-
: '#$streamName > ${hintTopic.displayName ?? store.realmEmptyTopicDisplayName}';
658+
: '#$streamName > '
659+
'${hintTopicStr.isEmpty ? store.realmEmptyTopicDisplayName : hintTopicStr}';
660660

661661
return _TypingNotifier(
662662
destination: TopicNarrow(widget.narrow.streamId,

test/widgets/compose_box_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ void main() {
398398
topicHintText: 'Topic',
399399
contentHintText: 'Message #${channel.name} > '
400400
'${eg.defaultRealmEmptyTopicDisplayName}');
401-
}, skip: true); // null topic names soon to be enabled
401+
});
402402

403403
testWidgets('legacy: with empty topic, content input has focus', (tester) async {
404404
await prepare(tester, narrow: narrow, mandatoryTopics: false,

0 commit comments

Comments
 (0)