Skip to content

Commit 96aeaf7

Browse files
committed
squash! implement retry UX
See if the tests can be simplified
1 parent 196333f commit 96aeaf7

11 files changed

+218
-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: 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';
@@ -1479,21 +1480,67 @@ class OutboxMessageWithPossibleSender extends StatelessWidget {
14791480

14801481
final MessageListOutboxMessageItem item;
14811482

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

0 commit comments

Comments
 (0)