Add optional SMAZ compression indicator icon on messages

This commit is contained in:
zjs81 committed 2026-11-21 04:10:43 -07:00
1 parent ae967ec21f
commit d76d488e45
36 files changed
+1321 -38

No files matched your search

+10 -1
View File
@@ -1,4 +1,5 @@
import 'dart:typed_data';
import '../connector/meshcore_protocol.dart';
import '../helpers/reaction_helper.dart';
import '../helpers/smaz.dart';
@@ -44,6 +45,7 @@ class ChannelMessage {
final DateTime receivedAt;
final bool isOutgoing;
final bool isBookmarked;
final bool isSmazCompressed;
final ChannelMessageStatus status;
final List<Repeat> repeats;
final int repeatCount;
@@ -79,6 +81,7 @@ class ChannelMessage {
DateTime? receivedAt,
required this.isOutgoing,
this.isBookmarked = false,
this.isSmazCompressed = false,
this.status = ChannelMessageStatus.pending,
this.repeats = const [],
this.repeatCount = 0,
@@ -120,6 +123,7 @@ class ChannelMessage {
ChannelMessage copyWith({
ChannelMessageStatus? status,
bool? isBookmarked,
bool? isSmazCompressed,
List<Repeat>? repeats,
int? repeatCount,
int? pathLength,
@@ -163,6 +167,7 @@ class ChannelMessage {
receivedAt: receivedAt,
isOutgoing: isOutgoing,
isBookmarked: isBookmarked ?? this.isBookmarked,
isSmazCompressed: isSmazCompressed ?? this.isSmazCompressed,
status: status ?? this.status,
repeats: repeats ?? this.repeats,
repeatCount: repeatCount ?? this.repeatCount,
@@ -252,7 +257,8 @@ class ChannelMessage {
}
}
final decodedText = Smaz.tryDecodePrefixed(actualText) ?? actualText;
final smazDecoded = Smaz.tryDecodePrefixed(actualText);
final decodedText = smazDecoded ?? actualText;
return ChannelMessage(
senderKey: null,
@@ -261,6 +267,7 @@ class ChannelMessage {
timestamp: DateTime.fromMillisecondsSinceEpoch(timestampRaw * 1000),
receivedAt: DateTime.now(),
isOutgoing: false,
isSmazCompressed: smazDecoded != null,
status: ChannelMessageStatus.sent,
pathLength: pathLen,
pathHashWidth: packetPathHashWidth,
@@ -283,6 +290,7 @@ class ChannelMessage {
String? translationModelId,
String? region,
ChannelMessage? replyTo,
bool isSmazCompressed = false,
}) {
return ChannelMessage(
senderKey: null,
@@ -296,6 +304,7 @@ class ChannelMessage {
replyToText: replyTo?.text,
timestamp: DateTime.now(),
isOutgoing: true,
isSmazCompressed: isSmazCompressed,
status: ChannelMessageStatus.pending,
pathLength: null,
pathBytes: Uint8List(0),