Merge pull request #686 from zjs81/fix/copy-full-and-special-messages
Preserve reply mentions and support copying image messages
This commit is contained in:
6 files changed
+703
-6
No files matched your search
@@ -60,7 +60,7 @@ class BookmarkedMessage {
|
||||
sourceName: channelName,
|
||||
messageId: message.messageId,
|
||||
senderName: senderName,
|
||||
text: message.text,
|
||||
text: message.fullText,
|
||||
translatedText: message.translatedText,
|
||||
timestamp: message.timestamp,
|
||||
receivedAt: message.receivedAt,
|
||||
|
||||
@@ -112,6 +112,17 @@ class ChannelMessage {
|
||||
|
||||
bool get isFiltered => filterReason != null;
|
||||
|
||||
/// Full wire/sent text, restoring the `@[sender] ` reply prefix when it
|
||||
/// was split into [replyToSenderName] on storage.
|
||||
String get fullText {
|
||||
if (replyToMessageId != null &&
|
||||
replyToSenderName != null &&
|
||||
replyToSenderName!.isNotEmpty) {
|
||||
return '@[$replyToSenderName] $text';
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
String? get senderKeyHex =>
|
||||
senderKey != null ? pubKeyToHex(senderKey!) : null;
|
||||
|
||||
|
||||
@@ -729,7 +729,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
|
||||
ChatSearchEntry(
|
||||
id: m.messageId,
|
||||
sender: m.senderName,
|
||||
text: m.text,
|
||||
text: m.fullText,
|
||||
translatedText: m.translatedText,
|
||||
time: m.receivedAt,
|
||||
matchSender: true,
|
||||
@@ -2540,6 +2540,14 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
|
||||
),
|
||||
subtitle: _imageSenderLabel(entry),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.copy),
|
||||
title: Text(l10n.common_copy),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
copyChatMessageText(context, _imageCopyText(entry));
|
||||
},
|
||||
),
|
||||
if (canSave)
|
||||
ListTile(
|
||||
leading: const Icon(Icons.save_alt),
|
||||
@@ -2592,6 +2600,17 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
|
||||
);
|
||||
}
|
||||
|
||||
String _imageCopyText(ReceivedImageEntry entry) {
|
||||
final l10n = context.l10n;
|
||||
final lines = <String>[
|
||||
'${_imageSenderLabel(entry)} (${formatChatTime(context, entry.firstSeen)})',
|
||||
l10n.receivedImage_awaiting(entry.bitstreamByteCount, entry.totalChunks),
|
||||
if (entry.state == ReceivedImageState.decoded && entry.synthesized)
|
||||
l10n.receivedImage_shareCaption(entry.bitstreamByteCount),
|
||||
];
|
||||
return lines.join('\n');
|
||||
}
|
||||
|
||||
Future<void> _saveImage(ReceivedImageEntry entry) async {
|
||||
final l10n = context.l10n;
|
||||
final shareOrigin = shareOriginOf(context);
|
||||
@@ -3095,7 +3114,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
|
||||
title: Text(context.l10n.common_copy),
|
||||
onTap: () {
|
||||
Navigator.pop(sheetContext);
|
||||
copyChatMessageText(context, message.text);
|
||||
copyChatMessageText(context, message.fullText);
|
||||
},
|
||||
),
|
||||
if (canTranslateMessage)
|
||||
@@ -3427,8 +3446,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen>
|
||||
final text = messages
|
||||
.map(
|
||||
(m) => m.senderName.isEmpty || m.isOutgoing
|
||||
? m.text
|
||||
: '${m.senderName}: ${m.text}',
|
||||
? m.fullText
|
||||
: '${m.senderName}: ${m.fullText}',
|
||||
)
|
||||
.join('\n');
|
||||
setState(_selectedIds.clear);
|
||||
|
||||
Reference in new issue
Block a user