Skip to content

Commit 713f167

Browse files
committed
msglist: Support retrieving failed outbox message content
1 parent 4d36a62 commit 713f167

11 files changed

+219
-18
lines changed

assets/l10n/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,10 @@
801801
"@messageIsMovedLabel": {
802802
"description": "Label for a moved message. (Use ALL CAPS for cased alphabets: Latin, Greek, Cyrillic, etc.)"
803803
},
804+
"messageIsntSentLabel": "MESSAGE ISN'T SENT. CHECK YOUR CONNECTION.",
805+
"@messageIsntSentLabel": {
806+
"description": "Label for a message that isn't sent. (Use ALL CAPS for cased alphabets: Latin, Greek, Cyrillic, etc.)"
807+
},
804808
"pollVoterNames": "({voterNames})",
805809
"@pollVoterNames": {
806810
"description": "The list of people who voted for a poll option, wrapped in parentheses.",

lib/generated/l10n/zulip_localizations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,12 @@ abstract class ZulipLocalizations {
11671167
/// **'MOVED'**
11681168
String get messageIsMovedLabel;
11691169

1170+
/// Label for a message that isn't sent. (Use ALL CAPS for cased alphabets: Latin, Greek, Cyrillic, etc.)
1171+
///
1172+
/// In en, this message translates to:
1173+
/// **'MESSAGE ISN\'T SENT. CHECK YOUR CONNECTION.'**
1174+
String get messageIsntSentLabel;
1175+
11701176
/// The list of people who voted for a poll option, wrapped in parentheses.
11711177
///
11721178
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
625625
@override
626626
String get messageIsMovedLabel => 'MOVED';
627627

628+
@override
629+
String get messageIsntSentLabel => 'MESSAGE ISN\'T SENT. CHECK YOUR CONNECTION.';
630+
628631
@override
629632
String pollVoterNames(String voterNames) {
630633
return '($voterNames)';

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
625625
@override
626626
String get messageIsMovedLabel => 'MOVED';
627627

628+
@override
629+
String get messageIsntSentLabel => 'MESSAGE ISN\'T SENT. CHECK YOUR CONNECTION.';
630+
628631
@override
629632
String pollVoterNames(String voterNames) {
630633
return '($voterNames)';

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
625625
@override
626626
String get messageIsMovedLabel => 'MOVED';
627627

628+
@override
629+
String get messageIsntSentLabel => 'MESSAGE ISN\'T SENT. CHECK YOUR CONNECTION.';
630+
628631
@override
629632
String pollVoterNames(String voterNames) {
630633
return '($voterNames)';

lib/generated/l10n/zulip_localizations_nb.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
625625
@override
626626
String get messageIsMovedLabel => 'MOVED';
627627

628+
@override
629+
String get messageIsntSentLabel => 'MESSAGE ISN\'T SENT. CHECK YOUR CONNECTION.';
630+
628631
@override
629632
String pollVoterNames(String voterNames) {
630633
return '($voterNames)';

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
625625
@override
626626
String get messageIsMovedLabel => 'PRZENIESIONO';
627627

628+
@override
629+
String get messageIsntSentLabel => 'MESSAGE ISN\'T SENT. CHECK YOUR CONNECTION.';
630+
628631
@override
629632
String pollVoterNames(String voterNames) {
630633
return '($voterNames)';

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
625625
@override
626626
String get messageIsMovedLabel => 'ПЕРЕМЕЩЕНО';
627627

628+
@override
629+
String get messageIsntSentLabel => 'MESSAGE ISN\'T SENT. CHECK YOUR CONNECTION.';
630+
628631
@override
629632
String pollVoterNames(String voterNames) {
630633
return '($voterNames)';

lib/generated/l10n/zulip_localizations_sk.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,9 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
625625
@override
626626
String get messageIsMovedLabel => 'PRESUNUTÉ';
627627

628+
@override
629+
String get messageIsntSentLabel => 'MESSAGE ISN\'T SENT. CHECK YOUR CONNECTION.';
630+
628631
@override
629632
String pollVoterNames(String voterNames) {
630633
return '($voterNames)';

lib/widgets/message_list.dart

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:intl/intl.dart' hide TextDirection;
88

99
import '../api/model/model.dart';
1010
import '../generated/l10n/zulip_localizations.dart';
11+
import '../model/message.dart';
1112
import '../model/message_list.dart';
1213
import '../model/narrow.dart';
1314
import '../model/store.dart';
@@ -1483,21 +1484,68 @@ class OutboxMessageWithPossibleSender extends StatelessWidget {
14831484

14841485
final MessageListOutboxMessageItem item;
14851486

1487+
// TODO should we restore the topic as well?
1488+
void _handlePress(BuildContext context) {
1489+
final content = item.message.content.endsWith('\n')
1490+
? item.message.content : '${item.message.content}\n';
1491+
1492+
final composeBoxController =
1493+
MessageListPage.ancestorOf(context).composeBoxController;
1494+
composeBoxController!.content.insertPadded(content);
1495+
if (!composeBoxController.contentFocusNode.hasFocus) {
1496+
composeBoxController.contentFocusNode.requestFocus();
1497+
}
1498+
1499+
final store = PerAccountStoreWidget.of(context);
1500+
assert(store.outboxMessages.containsKey(item.message.localMessageId));
1501+
store.removeOutboxMessage(item.message.localMessageId);
1502+
}
1503+
14861504
@override
14871505
Widget build(BuildContext context) {
1506+
final designVariables = DesignVariables.of(context);
1507+
final zulipLocalizations = ZulipLocalizations.of(context);
14881508
final message = item.message;
1489-
return Padding(
1490-
padding: const EdgeInsets.symmetric(vertical: 4),
1491-
child: Column(children: [
1492-
if (item.showSender) _SenderRow(message: message, showTimestamp: false),
1493-
Padding(
1494-
padding: const EdgeInsets.symmetric(horizontal: 16),
1495-
// This is adapated from [MessageContent].
1496-
// TODO(#576): Offer InheritedMessage ancestor once we are ready
1497-
// to support local echoing images and lightbox.
1498-
child: DefaultTextStyle(
1499-
style: ContentTheme.of(context).textStylePlainParagraph,
1500-
child: BlockContentList(nodes: item.content.nodes))),
1501-
]));
1509+
final opacity = message.state == OutboxMessageLifecycle.failed ? 0.6 : 1.0;
1510+
1511+
final isComposeBoxOffered =
1512+
MessageListPage.ancestorOf(context).composeBoxController != null;
1513+
1514+
return GestureDetector(
1515+
onTap: isComposeBoxOffered && message.state == OutboxMessageLifecycle.failed
1516+
? () => _handlePress(context) : null,
1517+
behavior: HitTestBehavior.opaque,
1518+
child: Padding(
1519+
padding: const EdgeInsets.symmetric(vertical: 4),
1520+
child: Column(children: [
1521+
if (item.showSender) Opacity(opacity: opacity,
1522+
child: _SenderRow(message: message, showTimestamp: false)),
1523+
Padding(
1524+
padding: const EdgeInsets.symmetric(horizontal: 16),
1525+
child: Column(crossAxisAlignment: CrossAxisAlignment.stretch,
1526+
children: [
1527+
Opacity(opacity: opacity,
1528+
// This is adapated from [MessageContent].
1529+
// TODO(#576): Offer InheritedMessage ancestor once we are ready
1530+
// to support local echoing images and lightbox.
1531+
child: DefaultTextStyle(
1532+
style: ContentTheme.of(context).textStylePlainParagraph,
1533+
child: BlockContentList(nodes: item.content.nodes))),
1534+
1535+
if (message.state == OutboxMessageLifecycle.failed)
1536+
Text(zulipLocalizations.messageIsntSentLabel,
1537+
textAlign: TextAlign.end,
1538+
style: TextStyle(
1539+
color: designVariables.btnLabelAttLowIntDanger,
1540+
fontSize: 12,
1541+
height: 12 / 12,
1542+
letterSpacing: proportionalLetterSpacing(
1543+
context, 0.006, baseFontSize: 12),
1544+
).merge(weightVariableTextStyle(context, wght: 400)))
1545+
else LinearProgressIndicator(minHeight: 2,
1546+
color: designVariables.foreground.withFadedAlpha(0.5),
1547+
backgroundColor: designVariables.foreground.withFadedAlpha(0.2)),
1548+
])),
1549+
])));
15021550
}
15031551
}

0 commit comments

Comments
 (0)