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
@@ -1,5 +1,6 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:meshcore_open/utils/app_logger.dart';
|
||||
|
||||
import '../models/channel_message.dart';
|
||||
@@ -160,6 +161,7 @@ class ChannelMessageStore {
|
||||
'receivedAt': msg.receivedAt.millisecondsSinceEpoch,
|
||||
'isOutgoing': msg.isOutgoing,
|
||||
'isBookmarked': msg.isBookmarked,
|
||||
'isSmazCompressed': msg.isSmazCompressed,
|
||||
'status': msg.status.index,
|
||||
'channelIndex': msg.channelIndex,
|
||||
'region': msg.region,
|
||||
@@ -186,9 +188,12 @@ class ChannelMessageStore {
|
||||
/// Convert JSON map to ChannelMessage
|
||||
ChannelMessage _messageFromJson(Map<String, dynamic> json) {
|
||||
final rawText = json['text'] as String;
|
||||
final decodedText = json['plainText'] == true
|
||||
? rawText
|
||||
: (Smaz.tryDecodePrefixed(rawText) ?? rawText);
|
||||
final smazDecoded = json['plainText'] == true
|
||||
? null
|
||||
: Smaz.tryDecodePrefixed(rawText);
|
||||
final decodedText = smazDecoded ?? rawText;
|
||||
final isSmazCompressed =
|
||||
json['isSmazCompressed'] as bool? ?? (smazDecoded != null);
|
||||
|
||||
final rawPathLength = json['pathLength'] as int?;
|
||||
final rawPathBytes = json['pathBytes'] != null
|
||||
@@ -238,6 +243,7 @@ class ChannelMessageStore {
|
||||
receivedAt: legacyAwareReceivedAt(json),
|
||||
isOutgoing: json['isOutgoing'] as bool? ?? false,
|
||||
isBookmarked: json['isBookmarked'] as bool? ?? false,
|
||||
isSmazCompressed: isSmazCompressed,
|
||||
status: _statusAt(json['status']) ?? ChannelMessageStatus.failed,
|
||||
repeatCount: (json['repeatCount'] as int?) ?? 0,
|
||||
pathLength: decodedPathLength,
|
||||
|
||||
@@ -202,6 +202,7 @@ class MessageStore {
|
||||
'isOutgoing': msg.isOutgoing,
|
||||
'isBookmarked': msg.isBookmarked,
|
||||
'isCli': msg.isCli,
|
||||
'isSmazCompressed': msg.isSmazCompressed,
|
||||
'status': msg.status.index,
|
||||
'messageId': msg.messageId,
|
||||
'originalText': msg.originalText,
|
||||
@@ -233,9 +234,12 @@ class MessageStore {
|
||||
Message _messageFromJson(Map<String, dynamic> json) {
|
||||
final rawText = json['text'] as String;
|
||||
final isCli = json['isCli'] as bool? ?? false;
|
||||
final decodedText = isCli || json['plainText'] == true
|
||||
? rawText
|
||||
: (Smaz.tryDecodePrefixed(rawText) ?? rawText);
|
||||
final smazDecoded = (isCli || json['plainText'] == true)
|
||||
? null
|
||||
: Smaz.tryDecodePrefixed(rawText);
|
||||
final decodedText = smazDecoded ?? rawText;
|
||||
final isSmazCompressed =
|
||||
json['isSmazCompressed'] as bool? ?? (smazDecoded != null);
|
||||
|
||||
final rawPathLength = json['pathLength'] as int?;
|
||||
final rawPathBytes = json['pathBytes'] != null
|
||||
@@ -273,6 +277,7 @@ class MessageStore {
|
||||
isOutgoing: json['isOutgoing'] as bool? ?? false,
|
||||
isBookmarked: json['isBookmarked'] as bool? ?? false,
|
||||
isCli: isCli,
|
||||
isSmazCompressed: isSmazCompressed,
|
||||
status: _statusAt(json['status']) ?? MessageStatus.failed,
|
||||
messageId: json['messageId'] as String?,
|
||||
originalText: json['originalText'] as String?,
|
||||
|
||||
Reference in new issue
Block a user