Skip to content

Commit 288926f

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 d33cba5 commit 288926f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

lib/widgets/compose_box.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ class _StreamContentInputState extends State<_StreamContentInput> {
624624
}
625625

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

642-
return TopicName(widget.controller.topic.textNormalized);
642+
return widget.controller.topic.textNormalized;
643643
}
644644

645645
@override
@@ -649,15 +649,15 @@ class _StreamContentInputState extends State<_StreamContentInput> {
649649

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

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

test/widgets/compose_box_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ void main() {
404404
topicHintText: 'Topic',
405405
contentHintText: 'Message #${channel.name} > '
406406
'${eg.defaultRealmEmptyTopicDisplayName}');
407-
}, skip: true); // null topic names soon to be enabled
407+
});
408408

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

0 commit comments

Comments
 (0)