Skip to content

Commit 92f38cb

Browse files
committed
compose: Use alternative placeholder if topics are mandatory and missing
Previously, the placeholder reads "#channel name > (no topic)" even if topics are mandatory for the realm. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 3129c8a commit 92f38cb

13 files changed

+94
-46
lines changed

assets/l10n/app_en.arb

+8-1
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,16 @@
348348
"@composeBoxSelfDmContentHint": {
349349
"description": "Hint text for content input when sending a message to yourself."
350350
},
351-
"composeBoxChannelContentHint": "Message #{channel} > {topic}",
351+
"composeBoxChannelContentHint": "Message #{channel}",
352352
"@composeBoxChannelContentHint": {
353353
"description": "Hint text for content input when sending a message to a channel",
354+
"placeholders": {
355+
"channel": {"type": "String", "example": "channel name"}
356+
}
357+
},
358+
"composeBoxChannelTopicContentHint": "Message #{channel} > {topic}",
359+
"@composeBoxChannelTopicContentHint": {
360+
"description": "Hint text for content input when sending a message to a topic in a channel",
354361
"placeholders": {
355362
"channel": {"type": "String", "example": "channel name"},
356363
"topic": {"type": "String", "example": "topic name"}

assets/l10n/app_pl.arb

-14
Original file line numberDiff line numberDiff line change
@@ -263,20 +263,6 @@
263263
"@composeBoxSelfDmContentHint": {
264264
"description": "Hint text for content input when sending a message to yourself."
265265
},
266-
"composeBoxChannelContentHint": "Wiadomość #{channel} > {topic}",
267-
"@composeBoxChannelContentHint": {
268-
"description": "Hint text for content input when sending a message to a channel",
269-
"placeholders": {
270-
"channel": {
271-
"type": "String",
272-
"example": "channel name"
273-
},
274-
"topic": {
275-
"type": "String",
276-
"example": "topic name"
277-
}
278-
}
279-
},
280266
"composeBoxTopicHintText": "Wątek",
281267
"@composeBoxTopicHintText": {
282268
"description": "Hint text for topic input widget in compose box."

assets/l10n/app_ru.arb

-14
Original file line numberDiff line numberDiff line change
@@ -373,20 +373,6 @@
373373
"@composeBoxGenericContentHint": {
374374
"description": "Hint text for content input when sending a message."
375375
},
376-
"composeBoxChannelContentHint": "Сообщение для #{channel} > {topic}",
377-
"@composeBoxChannelContentHint": {
378-
"description": "Hint text for content input when sending a message to a channel",
379-
"placeholders": {
380-
"channel": {
381-
"type": "String",
382-
"example": "channel name"
383-
},
384-
"topic": {
385-
"type": "String",
386-
"example": "topic name"
387-
}
388-
}
389-
},
390376
"composeBoxSendTooltip": "Отправить",
391377
"@composeBoxSendTooltip": {
392378
"description": "Tooltip for send button in compose box."

lib/generated/l10n/zulip_localizations.dart

+7-1
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,14 @@ abstract class ZulipLocalizations {
570570
/// Hint text for content input when sending a message to a channel
571571
///
572572
/// In en, this message translates to:
573+
/// **'Message #{channel}'**
574+
String composeBoxChannelContentHint(String channel);
575+
576+
/// Hint text for content input when sending a message to a topic in a channel
577+
///
578+
/// In en, this message translates to:
573579
/// **'Message #{channel} > {topic}'**
574-
String composeBoxChannelContentHint(String channel, String topic);
580+
String composeBoxChannelTopicContentHint(String channel, String topic);
575581

576582
/// Tooltip for send button in compose box.
577583
///

lib/generated/l10n/zulip_localizations_ar.dart

+6-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
276276
String get composeBoxSelfDmContentHint => 'Jot down something';
277277

278278
@override
279-
String composeBoxChannelContentHint(String channel, String topic) {
279+
String composeBoxChannelContentHint(String channel) {
280+
return 'Message #$channel';
281+
}
282+
283+
@override
284+
String composeBoxChannelTopicContentHint(String channel, String topic) {
280285
return 'Message #$channel > $topic';
281286
}
282287

lib/generated/l10n/zulip_localizations_en.dart

+6-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
276276
String get composeBoxSelfDmContentHint => 'Jot down something';
277277

278278
@override
279-
String composeBoxChannelContentHint(String channel, String topic) {
279+
String composeBoxChannelContentHint(String channel) {
280+
return 'Message #$channel';
281+
}
282+
283+
@override
284+
String composeBoxChannelTopicContentHint(String channel, String topic) {
280285
return 'Message #$channel > $topic';
281286
}
282287

lib/generated/l10n/zulip_localizations_ja.dart

+6-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
276276
String get composeBoxSelfDmContentHint => 'Jot down something';
277277

278278
@override
279-
String composeBoxChannelContentHint(String channel, String topic) {
279+
String composeBoxChannelContentHint(String channel) {
280+
return 'Message #$channel';
281+
}
282+
283+
@override
284+
String composeBoxChannelTopicContentHint(String channel, String topic) {
280285
return 'Message #$channel > $topic';
281286
}
282287

lib/generated/l10n/zulip_localizations_nb.dart

+6-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
276276
String get composeBoxSelfDmContentHint => 'Jot down something';
277277

278278
@override
279-
String composeBoxChannelContentHint(String channel, String topic) {
279+
String composeBoxChannelContentHint(String channel) {
280+
return 'Message #$channel';
281+
}
282+
283+
@override
284+
String composeBoxChannelTopicContentHint(String channel, String topic) {
280285
return 'Message #$channel > $topic';
281286
}
282287

lib/generated/l10n/zulip_localizations_pl.dart

+7-2
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,13 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
276276
String get composeBoxSelfDmContentHint => 'Zanotuj coś na przyszłość';
277277

278278
@override
279-
String composeBoxChannelContentHint(String channel, String topic) {
280-
return 'Wiadomość #$channel > $topic';
279+
String composeBoxChannelContentHint(String channel) {
280+
return 'Message #$channel';
281+
}
282+
283+
@override
284+
String composeBoxChannelTopicContentHint(String channel, String topic) {
285+
return 'Message #$channel > $topic';
281286
}
282287

283288
@override

lib/generated/l10n/zulip_localizations_ru.dart

+7-2
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,13 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
276276
String get composeBoxSelfDmContentHint => 'Сделать заметку';
277277

278278
@override
279-
String composeBoxChannelContentHint(String channel, String topic) {
280-
return 'Сообщение для #$channel > $topic';
279+
String composeBoxChannelContentHint(String channel) {
280+
return 'Message #$channel';
281+
}
282+
283+
@override
284+
String composeBoxChannelTopicContentHint(String channel, String topic) {
285+
return 'Message #$channel > $topic';
281286
}
282287

283288
@override

lib/generated/l10n/zulip_localizations_sk.dart

+6-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,12 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
276276
String get composeBoxSelfDmContentHint => 'Jot down something';
277277

278278
@override
279-
String composeBoxChannelContentHint(String channel, String topic) {
279+
String composeBoxChannelContentHint(String channel) {
280+
return 'Message #$channel';
281+
}
282+
283+
@override
284+
String composeBoxChannelTopicContentHint(String channel, String topic) {
280285
return 'Message #$channel > $topic';
281286
}
282287

lib/widgets/compose_box.dart

+6-3
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,11 @@ class _StreamContentInputState extends State<_StreamContentInput> {
587587
narrow: widget.narrow,
588588
destination: TopicNarrow(widget.narrow.streamId, topic),
589589
controller: widget.controller,
590-
hintText: zulipLocalizations.composeBoxChannelContentHint(
591-
streamName, topic.displayName));
590+
hintText: store.realmMandatoryTopics
591+
&& widget.controller.topic.isTopicEmpty
592+
? zulipLocalizations.composeBoxChannelContentHint(streamName)
593+
: zulipLocalizations.composeBoxChannelTopicContentHint(
594+
streamName, topic.displayName));
592595
}
593596
}
594597

@@ -646,7 +649,7 @@ class _FixedDestinationContentInput extends StatelessWidget {
646649
final store = PerAccountStoreWidget.of(context);
647650
final streamName = store.streams[streamId]?.name
648651
?? zulipLocalizations.unknownChannelName;
649-
return zulipLocalizations.composeBoxChannelContentHint(
652+
return zulipLocalizations.composeBoxChannelTopicContentHint(
650653
streamName, topic.displayName);
651654

652655
case DmNarrow(otherRecipientIds: []): // The self-1:1 thread.

test/widgets/compose_box_test.dart

+29-4
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
/// Check if the topic and content inputs use the expected hint texts.
@@ -352,17 +354,40 @@ void main() {
352354
of: contentInputFinder, matching: find.text(contentHintText))).findsOne();
353355
}
354356

355-
group('to ChannelNarrow', () {
357+
group('to ChannelNarrow, topics not mandatory', () {
356358
testWidgets('with empty topic', (tester) async {
357-
await prepare(tester, narrow: ChannelNarrow(channel.streamId));
359+
await prepare(tester, narrow: ChannelNarrow(channel.streamId),
360+
mandatoryTopics: false);
358361
checkComposeBoxHintTexts(tester,
359362
topicHintText: 'Topic',
360363
contentHintText: 'Message #${channel.name} > (no topic)');
361364
});
362365

363366
testWidgets('with non-empty topic', (tester) async {
364367
final narrow = ChannelNarrow(channel.streamId);
365-
await prepare(tester, narrow: narrow);
368+
await prepare(tester, narrow: narrow,
369+
mandatoryTopics: false);
370+
await enterTopic(tester, narrow: narrow, topic: 'new topic');
371+
await tester.pump();
372+
checkComposeBoxHintTexts(tester,
373+
topicHintText: 'Topic',
374+
contentHintText: 'Message #${channel.name} > new topic');
375+
});
376+
});
377+
378+
group('to ChannelNarrow, mandatory topics', () {
379+
testWidgets('with empty topic', (tester) async {
380+
await prepare(tester, narrow: ChannelNarrow(channel.streamId),
381+
mandatoryTopics: true);
382+
checkComposeBoxHintTexts(tester,
383+
topicHintText: 'Topic',
384+
contentHintText: 'Message #${channel.name}');
385+
});
386+
387+
testWidgets('with non-empty topic', (tester) async {
388+
final narrow = ChannelNarrow(channel.streamId);
389+
await prepare(tester, narrow: narrow,
390+
mandatoryTopics: true);
366391
await enterTopic(tester, narrow: narrow, topic: 'new topic');
367392
await tester.pump();
368393
checkComposeBoxHintTexts(tester,

0 commit comments

Comments
 (0)