remove voice code make optimizations. Fix channels race conditions. add reply function

This commit is contained in:
zach
2025-12-30 19:27:25 -07:00
parent 6ff950d426
commit baf92ef672
582 changed files with 814 additions and 179108 deletions
+37 -1
View File
@@ -34,6 +34,10 @@ class ChannelMessage {
final Uint8List pathBytes;
final List<Uint8List> pathVariants;
final int? channelIndex;
final String messageId;
final String? replyToMessageId;
final String? replyToSenderName;
final String? replyToText;
ChannelMessage({
this.senderKey,
@@ -48,7 +52,12 @@ class ChannelMessage {
Uint8List? pathBytes,
List<Uint8List>? pathVariants,
this.channelIndex,
}) : pathBytes = pathBytes ?? Uint8List(0),
String? messageId,
this.replyToMessageId,
this.replyToSenderName,
this.replyToText,
}) : messageId = messageId ?? '${timestamp.millisecondsSinceEpoch}_${senderName.hashCode}_${text.hashCode}',
pathBytes = pathBytes ?? Uint8List(0),
pathVariants = _mergePathVariants(
pathBytes ?? Uint8List(0),
pathVariants,
@@ -63,6 +72,9 @@ class ChannelMessage {
int? pathLength,
Uint8List? pathBytes,
List<Uint8List>? pathVariants,
String? replyToMessageId,
String? replyToSenderName,
String? replyToText,
}) {
return ChannelMessage(
senderKey: senderKey,
@@ -77,6 +89,10 @@ class ChannelMessage {
pathBytes: pathBytes ?? this.pathBytes,
pathVariants: pathVariants ?? this.pathVariants,
channelIndex: channelIndex,
messageId: messageId,
replyToMessageId: replyToMessageId ?? this.replyToMessageId,
replyToSenderName: replyToSenderName ?? this.replyToSenderName,
replyToText: replyToText ?? this.replyToText,
);
}
@@ -207,4 +223,24 @@ class ChannelMessage {
}
return true;
}
static ReplyInfo? parseReplyMention(String text) {
final regex = RegExp(r'^@\[([^\]]+)\]\s+(.+)$', dotAll: true);
final match = regex.firstMatch(text);
if (match == null) return null;
return ReplyInfo(
mentionedNode: match.group(1)!,
actualMessage: match.group(2)!,
);
}
}
class ReplyInfo {
final String mentionedNode;
final String actualMessage;
ReplyInfo({
required this.mentionedNode,
required this.actualMessage,
});
}
-18
View File
@@ -10,10 +10,6 @@ class Message {
final bool isOutgoing;
final bool isCli;
final MessageStatus status;
final bool isVoice;
final String? voicePath;
final int? voiceDurationMs;
final String? voiceCodec;
// NEW: Retry logic fields
final String? messageId;
@@ -34,10 +30,6 @@ class Message {
required this.isOutgoing,
this.isCli = false,
this.status = MessageStatus.pending,
this.isVoice = false,
this.voicePath,
this.voiceDurationMs,
this.voiceCodec,
this.messageId,
this.retryCount = 0,
this.estimatedTimeoutMs,
@@ -63,10 +55,6 @@ class Message {
int? pathLength,
Uint8List? pathBytes,
bool? isCli,
bool? isVoice,
String? voicePath,
int? voiceDurationMs,
String? voiceCodec,
}) {
return Message(
senderKey: senderKey,
@@ -75,10 +63,6 @@ class Message {
isOutgoing: isOutgoing,
isCli: isCli ?? this.isCli,
status: status ?? this.status,
isVoice: isVoice ?? this.isVoice,
voicePath: voicePath ?? this.voicePath,
voiceDurationMs: voiceDurationMs ?? this.voiceDurationMs,
voiceCodec: voiceCodec ?? this.voiceCodec,
messageId: messageId,
retryCount: retryCount ?? this.retryCount,
estimatedTimeoutMs: estimatedTimeoutMs ?? this.estimatedTimeoutMs,
@@ -117,7 +101,6 @@ class Message {
isOutgoing: false,
isCli: false,
status: MessageStatus.delivered,
isVoice: false,
pathBytes: Uint8List(0),
);
}
@@ -135,7 +118,6 @@ class Message {
isOutgoing: true,
isCli: false,
status: MessageStatus.pending,
isVoice: false,
pathLength: pathLength,
pathBytes: pathBytes,
);