Skip to content

Commit 66614ca

Browse files
committed
squash! implement retry UX
See if the tests can be simplified
1 parent 5f76af5 commit 66614ca

11 files changed

+219
-17
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: 60 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';
@@ -1481,21 +1482,67 @@ class OutboxMessageWithPossibleSender extends StatelessWidget {
14811482

14821483
final MessageListOutboxMessageItem item;
14831484

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

0 commit comments

Comments
 (0)