Skip to content

Commit 47bbfe2

Browse files
PIG208gnprice
authored andcommitted
compose [nfc]: Handle empty topics for topic-narrow input hint text
While this appears to be a user facing change, it's not visible yet, not until TopicName.displayName becomes nullable. This is a part of a series of changes to handle empty topics. A test is skipped because the server does not send empty topics to the client without "empty_topic_name" client capability. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 51616bd commit 47bbfe2

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

lib/widgets/compose_box.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,8 @@ class _FixedDestinationContentInput extends StatelessWidget {
658658
// Zulip expresses channels and topics, not any normal English punctuation,
659659
// so don't make sense to translate. See:
660660
// https://github.com/zulip/zulip-flutter/pull/1148#discussion_r1941990585
661-
'#$streamName > ${topic.displayName}');
661+
// ignore: dead_null_aware_expression // null topic names soon to be enabled
662+
'#$streamName > ${topic.displayName ?? store.realmEmptyTopicDisplayName}');
662663

663664
case DmNarrow(otherRecipientIds: []): // The self-1:1 thread.
664665
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)