Skip to content

local echo (6.5/7): Revised prep commits for local echo #1535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@
"@discardDraftConfirmationDialogTitle": {
"description": "Title for a confirmation dialog for discarding message text that was typed into the compose box."
},
"discardDraftConfirmationDialogMessage": "When you edit a message, the content that was previously in the compose box is discarded.",
"@discardDraftConfirmationDialogMessage": {
"description": "Message for a confirmation dialog for discarding message text that was typed into the compose box."
"discardDraftForEditConfirmationDialogMessage": "When you edit a message, the content that was previously in the compose box is discarded.",
"@discardDraftForEditConfirmationDialogMessage": {
"description": "Message for a confirmation dialog for discarding message text that was typed into the compose box, when editing a message."
},
"discardDraftConfirmationDialogConfirmButton": "Discard",
"@discardDraftConfirmationDialogConfirmButton": {
Expand Down
6 changes: 3 additions & 3 deletions assets/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1049,9 +1049,9 @@
"@discardDraftConfirmationDialogTitle": {
"description": "Title for a confirmation dialog for discarding message text that was typed into the compose box."
},
"discardDraftConfirmationDialogMessage": "Miej na uwadze, że przechodząc do zmiany wiadomości wyczyścisz okno nowej wiadomości.",
"@discardDraftConfirmationDialogMessage": {
"description": "Message for a confirmation dialog for discarding message text that was typed into the compose box."
"discardDraftForEditConfirmationDialogMessage": "Miej na uwadze, że przechodząc do zmiany wiadomości wyczyścisz okno nowej wiadomości.",
"@discardDraftForEditConfirmationDialogMessage": {
"description": "Message for a confirmation dialog for discarding message text that was typed into the compose box, when editing a message."
},
"discardDraftConfirmationDialogConfirmButton": "Odrzuć",
"@discardDraftConfirmationDialogConfirmButton": {
Expand Down
4 changes: 2 additions & 2 deletions assets/l10n/app_ru.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1069,8 +1069,8 @@
"@editAlreadyInProgressMessage": {
"description": "Error message when a message edit cannot be saved because there is another edit already in progress."
},
"discardDraftConfirmationDialogMessage": "При изменении сообщения текст из поля для редактирования удаляется.",
"@discardDraftConfirmationDialogMessage": {
"discardDraftForEditConfirmationDialogMessage": "При изменении сообщения текст из поля для редактирования удаляется.",
"@discardDraftForEditConfirmationDialogMessage": {
"description": "Message for a confirmation dialog for discarding message text that was typed into the compose box."
}
}
4 changes: 2 additions & 2 deletions lib/generated/l10n/zulip_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,11 @@ abstract class ZulipLocalizations {
/// **'Discard the message you’re writing?'**
String get discardDraftConfirmationDialogTitle;

/// Message for a confirmation dialog for discarding message text that was typed into the compose box.
/// Message for a confirmation dialog for discarding message text that was typed into the compose box, when editing a message.
///
/// In en, this message translates to:
/// **'When you edit a message, the content that was previously in the compose box is discarded.'**
String get discardDraftConfirmationDialogMessage;
String get discardDraftForEditConfirmationDialogMessage;

/// Label for the 'Discard' button on a confirmation dialog for discarding message text that was typed into the compose box.
///
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/l10n/zulip_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
'Discard the message you’re writing?';

@override
String get discardDraftConfirmationDialogMessage =>
String get discardDraftForEditConfirmationDialogMessage =>
'When you edit a message, the content that was previously in the compose box is discarded.';

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/l10n/zulip_localizations_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class ZulipLocalizationsDe extends ZulipLocalizations {
'Discard the message you’re writing?';

@override
String get discardDraftConfirmationDialogMessage =>
String get discardDraftForEditConfirmationDialogMessage =>
'When you edit a message, the content that was previously in the compose box is discarded.';

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/l10n/zulip_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
'Discard the message you’re writing?';

@override
String get discardDraftConfirmationDialogMessage =>
String get discardDraftForEditConfirmationDialogMessage =>
'When you edit a message, the content that was previously in the compose box is discarded.';

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/l10n/zulip_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
'Discard the message you’re writing?';

@override
String get discardDraftConfirmationDialogMessage =>
String get discardDraftForEditConfirmationDialogMessage =>
'When you edit a message, the content that was previously in the compose box is discarded.';

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/l10n/zulip_localizations_nb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
'Discard the message you’re writing?';

@override
String get discardDraftConfirmationDialogMessage =>
String get discardDraftForEditConfirmationDialogMessage =>
'When you edit a message, the content that was previously in the compose box is discarded.';

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/l10n/zulip_localizations_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
'Czy chcesz przerwać szykowanie wpisu?';

@override
String get discardDraftConfirmationDialogMessage =>
String get discardDraftForEditConfirmationDialogMessage =>
'Miej na uwadze, że przechodząc do zmiany wiadomości wyczyścisz okno nowej wiadomości.';

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/l10n/zulip_localizations_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
'Отказаться от написанного сообщения?';

@override
String get discardDraftConfirmationDialogMessage =>
String get discardDraftForEditConfirmationDialogMessage =>
'При изменении сообщения текст из поля для редактирования удаляется.';

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/l10n/zulip_localizations_sk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
'Discard the message you’re writing?';

@override
String get discardDraftConfirmationDialogMessage =>
String get discardDraftForEditConfirmationDialogMessage =>
'When you edit a message, the content that was previously in the compose box is discarded.';

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/l10n/zulip_localizations_uk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class ZulipLocalizationsUk extends ZulipLocalizations {
'Discard the message you’re writing?';

@override
String get discardDraftConfirmationDialogMessage =>
String get discardDraftForEditConfirmationDialogMessage =>
'When you edit a message, the content that was previously in the compose box is discarded.';

@override
Expand Down
2 changes: 1 addition & 1 deletion lib/generated/l10n/zulip_localizations_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class ZulipLocalizationsZh extends ZulipLocalizations {
'Discard the message you’re writing?';

@override
String get discardDraftConfirmationDialogMessage =>
String get discardDraftForEditConfirmationDialogMessage =>
'When you edit a message, the content that was previously in the compose box is discarded.';

@override
Expand Down
14 changes: 9 additions & 5 deletions lib/widgets/compose_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1849,11 +1849,13 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM

@override
void startEditInteraction(int messageId) async {
if (await _abortBecauseContentInputNotEmpty()) return;
if (!mounted) return;
final zulipLocalizations = ZulipLocalizations.of(context);

final abort = await _abortBecauseContentInputNotEmpty(
dialogMessage: zulipLocalizations.discardDraftForEditConfirmationDialogMessage);
if (abort || !mounted) return;

final store = PerAccountStoreWidget.of(context);
final zulipLocalizations = ZulipLocalizations.of(context);

switch (store.getEditMessageErrorStatus(messageId)) {
case null:
Expand All @@ -1878,12 +1880,14 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM

/// If there's text in the compose box, give a confirmation dialog
/// asking if it can be discarded and await the result.
Future<bool> _abortBecauseContentInputNotEmpty() async {
Future<bool> _abortBecauseContentInputNotEmpty({
required String dialogMessage,
}) async {
final zulipLocalizations = ZulipLocalizations.of(context);
if (controller.content.textNormalized.isNotEmpty) {
final dialog = showSuggestedActionDialog(context: context,
title: zulipLocalizations.discardDraftConfirmationDialogTitle,
message: zulipLocalizations.discardDraftConfirmationDialogMessage,
message: dialogMessage,
// TODO(#1032) "destructive" style for action button
actionButtonText: zulipLocalizations.discardDraftConfirmationDialogConfirmButton);
if (await dialog.result != true) return true;
Expand Down
76 changes: 43 additions & 33 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ final _kMessageTimestampFormat = DateFormat('h:mm aa', 'en_US');
class _SenderRow extends StatelessWidget {
const _SenderRow({required this.message, required this.showTimestamp});

final Message message;
final MessageBase message;
final bool showTimestamp;

@override
Expand Down Expand Up @@ -1446,7 +1446,9 @@ class _SenderRow extends StatelessWidget {
userId: message.senderId),
const SizedBox(width: 8),
Flexible(
child: Text(message.senderFullName, // TODO(#716): use `store.senderDisplayName`
child: Text(message is Message
? store.senderDisplayName(message as Message)
: store.userDisplayName(message.senderId),
style: TextStyle(
fontSize: 18,
height: (22 / 18),
Expand Down Expand Up @@ -1535,7 +1537,7 @@ class MessageWithPossibleSender extends StatelessWidget {
behavior: HitTestBehavior.translucent,
onLongPress: () => showMessageActionSheet(context: context, message: message),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
padding: const EdgeInsets.only(top: 4),
child: Column(children: [
if (item.showSender)
_SenderRow(message: message, showTimestamp: true),
Expand All @@ -1553,14 +1555,18 @@ class MessageWithPossibleSender extends StatelessWidget {
if (editMessageErrorStatus != null)
_EditMessageStatusRow(messageId: message.id, status: editMessageErrorStatus)
else if (editStateText != null)
Text(editStateText,
textAlign: TextAlign.end,
style: TextStyle(
color: designVariables.labelEdited,
fontSize: 12,
height: (12 / 12),
letterSpacing: proportionalLetterSpacing(
context, 0.05, baseFontSize: 12))),
Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Text(editStateText,
textAlign: TextAlign.end,
style: TextStyle(
color: designVariables.labelEdited,
fontSize: 12,
height: (12 / 12),
letterSpacing: proportionalLetterSpacing(context,
0.05, baseFontSize: 12))))
else
Padding(padding: const EdgeInsets.only(bottom: 4))
])),
SizedBox(width: 16,
child: star),
Expand Down Expand Up @@ -1591,30 +1597,34 @@ class _EditMessageStatusRow extends StatelessWidget {

return switch (status) {
// TODO parse markdown and show new content as local echo?
false => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: 1.5,
children: [
Text(
false => Padding(
padding: const EdgeInsets.only(bottom: 2),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
spacing: 1.5,
children: [
Text(
style: baseTextStyle
.copyWith(color: designVariables.btnLabelAttLowIntInfo),
textAlign: TextAlign.end,
zulipLocalizations.savingMessageEditLabel),
// TODO instead place within bottom outer padding:
// https://github.com/zulip/zulip-flutter/pull/1498#discussion_r2087576108
LinearProgressIndicator(
minHeight: 2,
color: designVariables.foreground.withValues(alpha: 0.5),
backgroundColor: designVariables.foreground.withValues(alpha: 0.2),
),
])),
true => Padding(
padding: const EdgeInsets.only(bottom: 4),
child: _RestoreEditMessageGestureDetector(
messageId: messageId,
child: Text(
style: baseTextStyle
.copyWith(color: designVariables.btnLabelAttLowIntInfo),
.copyWith(color: designVariables.btnLabelAttLowIntDanger),
textAlign: TextAlign.end,
zulipLocalizations.savingMessageEditLabel),
// TODO instead place within bottom outer padding:
// https://github.com/zulip/zulip-flutter/pull/1498#discussion_r2087576108
LinearProgressIndicator(
minHeight: 2,
color: designVariables.foreground.withValues(alpha: 0.5),
backgroundColor: designVariables.foreground.withValues(alpha: 0.2),
),
]),
true => _RestoreEditMessageGestureDetector(
messageId: messageId,
child: Text(
style: baseTextStyle
.copyWith(color: designVariables.btnLabelAttLowIntDanger),
textAlign: TextAlign.end,
zulipLocalizations.savingMessageEditFailedLabel)),
zulipLocalizations.savingMessageEditFailedLabel))),
};
}
}
Expand Down
Loading