Skip to content

Commit 58463a5

Browse files
committed
do not merge; compose: Handle hint text for empty topics
This is a placeholder before we actually handle empty topics for compose box in general. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 94c2949 commit 58463a5

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

lib/widgets/compose_box.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,10 @@ class _StreamContentInputState extends State<_StreamContentInput> {
586586
final streamName = store.streams[widget.narrow.streamId]?.name
587587
?? zulipLocalizations.unknownChannelName;
588588
final topic = TopicName(widget.controller.topic.textNormalized);
589+
// Until we support sending to empty topics, `topic.displayName` will remain
590+
// non-null because the topic input text gets normalized to "(no topic)".
591+
// ignore: unnecessary_null_comparison // null topic names soon to be enabled
592+
assert(topic.displayName != null);
589593
return _ContentInput(
590594
narrow: widget.narrow,
591595
destination: TopicNarrow(widget.narrow.streamId, topic),
@@ -658,7 +662,8 @@ class _FixedDestinationContentInput extends StatelessWidget {
658662
// Zulip expresses channels and topics, not any normal English punctuation,
659663
// so don't make sense to translate. See:
660664
// https://github.com/zulip/zulip-flutter/pull/1148#discussion_r1941990585
661-
'#$streamName > ${topic.displayName}');
665+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
666+
'#$streamName > ${topic.displayName ?? store.realmEmptyTopicDisplayName}');
662667

663668
case DmNarrow(otherRecipientIds: []): // The self-1:1 thread.
664669
return zulipLocalizations.composeBoxSelfDmContentHint;

test/widgets/compose_box_test.dart

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,20 @@ void main() {
370370
});
371371
});
372372

373-
testWidgets('to TopicNarrow', (tester) async {
374-
await prepare(tester,
375-
narrow: TopicNarrow(channel.streamId, TopicName('topic')));
376-
checkComposeBoxHintTexts(tester,
377-
contentHintText: 'Message #${channel.name} > topic');
373+
group('to TopicNarrow', () {
374+
testWidgets('with non-empty topic', (tester) async {
375+
await prepare(tester,
376+
narrow: TopicNarrow(channel.streamId, TopicName('topic')));
377+
checkComposeBoxHintTexts(tester,
378+
contentHintText: 'Message #${channel.name} > topic');
379+
});
380+
381+
testWidgets('with empty topic', (tester) async {
382+
await prepare(tester,
383+
narrow: TopicNarrow(channel.streamId, TopicName('')));
384+
checkComposeBoxHintTexts(tester, contentHintText:
385+
'Message #${channel.name} > ${eg.defaultRealmEmptyTopicDisplayName}');
386+
}, skip: true); // null topic names soon to be enabled
378387
});
379388

380389
testWidgets('to DmNarrow with self', (tester) async {

0 commit comments

Comments
 (0)