Add optional SMAZ compression indicator icon on messages
This commit is contained in:
1 parent
ae967ec21f
commit
d76d488e45
36 files changed
+1321
-38
No files matched your search
+12
-1
@@ -1,6 +1,8 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import '../connector/meshcore_protocol.dart';
|
||||
import '../helpers/reaction_helper.dart';
|
||||
import '../helpers/smaz.dart';
|
||||
import 'translation_support.dart';
|
||||
|
||||
enum MessageStatus { pending, sent, delivered, failed }
|
||||
@@ -36,6 +38,7 @@ class Message {
|
||||
final bool isOutgoing;
|
||||
final bool isBookmarked;
|
||||
final bool isCli;
|
||||
final bool isSmazCompressed;
|
||||
final MessageStatus status;
|
||||
final String? originalText;
|
||||
final String? translatedText;
|
||||
@@ -65,6 +68,7 @@ class Message {
|
||||
required this.isOutgoing,
|
||||
this.isBookmarked = false,
|
||||
this.isCli = false,
|
||||
this.isSmazCompressed = false,
|
||||
this.status = MessageStatus.pending,
|
||||
String? messageId,
|
||||
this.originalText,
|
||||
@@ -110,6 +114,7 @@ class Message {
|
||||
int? pathLength,
|
||||
Uint8List? pathBytes,
|
||||
bool? isCli,
|
||||
bool? isSmazCompressed,
|
||||
bool? isBookmarked,
|
||||
Object? originalText = _unset,
|
||||
Object? translatedText = _unset,
|
||||
@@ -128,6 +133,7 @@ class Message {
|
||||
isOutgoing: isOutgoing,
|
||||
isBookmarked: isBookmarked ?? this.isBookmarked,
|
||||
isCli: isCli ?? this.isCli,
|
||||
isSmazCompressed: isSmazCompressed ?? this.isSmazCompressed,
|
||||
status: status ?? this.status,
|
||||
messageId: messageId,
|
||||
originalText: originalText == _unset
|
||||
@@ -173,7 +179,9 @@ class Message {
|
||||
if ((flags >> 2) != txtTypePlain) {
|
||||
return null;
|
||||
}
|
||||
final text = reader.readCString();
|
||||
final rawText = reader.readCString();
|
||||
final smazDecoded = Smaz.tryDecodePrefixed(rawText);
|
||||
final text = smazDecoded ?? rawText;
|
||||
|
||||
return Message(
|
||||
senderKey: senderKey,
|
||||
@@ -182,6 +190,7 @@ class Message {
|
||||
receivedAt: DateTime.now(),
|
||||
isOutgoing: false,
|
||||
isCli: false,
|
||||
isSmazCompressed: smazDecoded != null,
|
||||
status: MessageStatus.delivered,
|
||||
pathBytes: Uint8List(0),
|
||||
);
|
||||
@@ -198,6 +207,7 @@ class Message {
|
||||
String? translationModelId,
|
||||
int? pathLength,
|
||||
Uint8List? pathBytes,
|
||||
bool isSmazCompressed = false,
|
||||
}) {
|
||||
return Message(
|
||||
senderKey: recipientKey,
|
||||
@@ -208,6 +218,7 @@ class Message {
|
||||
timestamp: DateTime.now(),
|
||||
isOutgoing: true,
|
||||
isCli: false,
|
||||
isSmazCompressed: isSmazCompressed,
|
||||
status: MessageStatus.pending,
|
||||
pathLength: pathLength,
|
||||
pathBytes: pathBytes,
|
||||
|
||||
Reference in new issue
Block a user