Skip to content
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
8 changes: 8 additions & 0 deletions assets/translations/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@
"attachmentSaveFailed": "Uložení přílohy se nepovedlo",
"forwardTo": "Přeposlat komu",
"forwarded": "Přeposláno",
"showFull": "Zobrazit více",
"showLess": "Zobrazit méně",
"newMessages": "Nové zprávy",
"selectedCount": "Vybráno: %d",
"moreActions": "Další akce",
"jumpToLatest": "Skočit na nejnovější",
"chatPinned": "Chat připnut",
"chatUnpinned": "Chat odebrán z připnutých",
"noChatsToForward": "Zatím žádné chaty, vyhledej uživatele",
"mediaFile": "Soubor",
"fileTooLarge": "Soubor je příliš velký, maximum je",
Expand Down
8 changes: 8 additions & 0 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@
"attachmentSaveFailed": "Saving the attachment failed",
"forwardTo": "Forward to",
"forwarded": "Forwarded",
"showFull": "Show full message",
"showLess": "Show less",
"newMessages": "New messages",
"selectedCount": "%d selected",
"moreActions": "More actions",
"jumpToLatest": "Jump to latest",
"chatPinned": "Chat pinned",
"chatUnpinned": "Chat unpinned",
"noChatsToForward": "No chats yet, search for a user",
"mediaFile": "File",
"fileTooLarge": "File is too large, the maximum is",
Expand Down
41 changes: 41 additions & 0 deletions lib/models/private_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:hive/hive.dart';
import 'package:whisper_websocket_client_dart/models/media_type.dart';

import '../utils/singleton.dart';
import '../utils/text_envelope.dart';

part 'private_message.g.dart';

Expand Down Expand Up @@ -162,6 +163,19 @@ class PrivateMessage extends HiveObject {
@HiveField(15)
String? albumJson;

/// Sender of the message this one quotes, null when it is not a reply.
@HiveField(16)
String? replyToSenderId;

/// Client timestamp of the quoted message, null when it is not a reply.
@HiveField(17)
DateTime? replyToSentAt;

/// Preview of the quoted message, kept here so the quote survives its
/// original being deleted on this device.
@HiveField(18)
String? replyToPreview;

/// Cache for [album], keyed by the [albumJson] it was decoded from.
String? _albumCacheJson;
List<AlbumItem>? _albumCache;
Expand All @@ -183,8 +197,35 @@ class PrivateMessage extends HiveObject {
this.fileName,
this.sendStatus = SendStatus.sent,
this.albumJson,
this.replyToSenderId,
this.replyToSentAt,
this.replyToPreview,
});

/// The quoted message, or null when this message is not a reply.
ReplyRef? get replyTo {
final senderId = replyToSenderId;
final sentAt = replyToSentAt;
if (senderId == null || sentAt == null) {
return null;
}
return ReplyRef(
senderId: senderId,
sentAt: sentAt,
preview: replyToPreview ?? '',
);
}

/// Stores (or clears) the message this one quotes.
void setReplyTo(ReplyRef? reply) {
replyToSenderId = reply?.senderId;
replyToSentAt = reply?.sentAt;
replyToPreview = reply?.preview;
}

/// Whether this message quotes another one.
bool get isReply => replyToSentAt != null;

/// Stored instead of the text when a message cannot be decrypted. It keeps a
/// visible gap in the chat, and the receiver only acks what it stored, so the
/// server still has the ciphertext.
Expand Down
13 changes: 11 additions & 2 deletions lib/models/private_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading