Skip to content

Commit eb461ff

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 811d107 commit eb461ff

13 files changed

+92
-46
lines changed

Diff for: 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"}

Diff for: 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."

Diff for: 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."

Diff for: 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
///

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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.

Diff for: test/widgets/compose_box_test.dart

+27-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
void checkComposeBoxHintTexts(WidgetTester tester, {
@@ -347,17 +349,19 @@ void main() {
347349
of: contentInputFinder, matching: find.text(contentHintText))).findsOne();
348350
}
349351

350-
group('to ChannelNarrow', () {
352+
group('to ChannelNarrow, topics not mandatory', () {
351353
testWidgets('with empty topic', (tester) async {
352-
await prepare(tester, narrow: ChannelNarrow(channel.streamId));
354+
await prepare(tester, narrow: ChannelNarrow(channel.streamId),
355+
mandatoryTopics: false);
353356
checkComposeBoxHintTexts(tester,
354357
topicHintText: 'Topic',
355358
contentHintText: 'Message #${channel.name} > (no topic)');
356359
});
357360

358361
testWidgets('with non-empty topic', (tester) async {
359362
final narrow = ChannelNarrow(channel.streamId);
360-
await prepare(tester, narrow: narrow);
363+
await prepare(tester, narrow: narrow,
364+
mandatoryTopics: false);
361365
await enterTopic(tester, narrow: narrow, topic: 'new topic');
362366
await tester.pump();
363367
checkComposeBoxHintTexts(tester,
@@ -366,6 +370,25 @@ void main() {
366370
});
367371
});
368372

373+
testWidgets('to ChannelNarrow, mandatory topics with empty topic', (tester) async {
374+
await prepare(tester, narrow: ChannelNarrow(channel.streamId),
375+
mandatoryTopics: true);
376+
checkComposeBoxHintTexts(tester,
377+
topicHintText: 'Topic',
378+
contentHintText: 'Message #${channel.name}');
379+
});
380+
381+
testWidgets('to ChannelNarrow, mandatory topics with non-empty topic', (tester) async {
382+
final narrow = ChannelNarrow(channel.streamId);
383+
await prepare(tester, narrow: narrow,
384+
mandatoryTopics: true);
385+
await enterTopic(tester, narrow: narrow, topic: 'new topic');
386+
await tester.pump();
387+
checkComposeBoxHintTexts(tester,
388+
topicHintText: 'Topic',
389+
contentHintText: 'Message #${channel.name} > new topic');
390+
});
391+
369392
testWidgets('to TopicNarrow', (tester) async {
370393
await prepare(tester,
371394
narrow: TopicNarrow(channel.streamId, TopicName('topic')));

0 commit comments

Comments
 (0)