Skip to content

Commit 9a5f3af

Browse files
committed
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 a0732f9 commit 9a5f3af

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
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: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,13 @@ void main() {
326326

327327
Future<void> prepare(WidgetTester tester, {
328328
required Narrow narrow,
329+
bool? mandatoryTopics,
329330
}) async {
330331
await prepareComposeBox(tester,
331332
narrow: narrow,
332333
otherUsers: [eg.otherUser, eg.thirdUser],
333-
streams: [channel]);
334+
streams: [channel],
335+
mandatoryTopics: mandatoryTopics);
334336
}
335337

336338
/// This checks the input's configured hint text without regard to whether
@@ -371,11 +373,20 @@ void main() {
371373
});
372374
});
373375

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

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

0 commit comments

Comments
 (0)