mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-26 21:46:38 +10:00
fix reply colors and reaction counts also fix race condition when connecting
This commit is contained in:
@@ -1955,10 +1955,19 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
// Parse reaction info
|
// Parse reaction info
|
||||||
final reactionInfo = Message.parseReaction(message.text);
|
final reactionInfo = Message.parseReaction(message.text);
|
||||||
if (reactionInfo != null) {
|
if (reactionInfo != null) {
|
||||||
// Find target message and add reaction
|
// Check if we've already processed this exact reaction
|
||||||
_processContactReaction(messages, reactionInfo);
|
final isDuplicate = messages.any((m) =>
|
||||||
_messageStore.saveMessages(pubKeyHex, messages);
|
m.text == message.text &&
|
||||||
notifyListeners();
|
m.senderKey == message.senderKey &&
|
||||||
|
m.timestamp.millisecondsSinceEpoch == message.timestamp.millisecondsSinceEpoch
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isDuplicate) {
|
||||||
|
// New reaction - process it
|
||||||
|
_processContactReaction(messages, reactionInfo);
|
||||||
|
_messageStore.saveMessages(pubKeyHex, messages);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
return; // Don't add reaction as a visible message
|
return; // Don't add reaction as a visible message
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2095,10 +2104,20 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
// Parse reaction info
|
// Parse reaction info
|
||||||
final reactionInfo = ChannelMessage.parseReaction(message.text);
|
final reactionInfo = ChannelMessage.parseReaction(message.text);
|
||||||
if (reactionInfo != null) {
|
if (reactionInfo != null) {
|
||||||
// Find target message and add reaction
|
// Check if we've already processed this exact reaction by looking for duplicate in messages
|
||||||
_processReaction(messages, reactionInfo);
|
// Reaction messages are kept in the list but won't be displayed (filtered in UI or here)
|
||||||
// Save updated messages
|
final isDuplicate = messages.any((m) =>
|
||||||
_channelMessageStore.saveChannelMessages(channelIndex, messages);
|
m.text == message.text &&
|
||||||
|
m.senderName == message.senderName &&
|
||||||
|
m.timestamp.millisecondsSinceEpoch == message.timestamp.millisecondsSinceEpoch
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!isDuplicate) {
|
||||||
|
// New reaction - process it
|
||||||
|
_processReaction(messages, reactionInfo);
|
||||||
|
// Save updated messages
|
||||||
|
_channelMessageStore.saveChannelMessages(channelIndex, messages);
|
||||||
|
}
|
||||||
return false; // Don't add reaction as a visible message
|
return false; // Don't add reaction as a visible message
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2302,8 +2321,8 @@ class MeshCoreConnector extends ChangeNotifier {
|
|||||||
_device = null;
|
_device = null;
|
||||||
_rxCharacteristic = null;
|
_rxCharacteristic = null;
|
||||||
_txCharacteristic = null;
|
_txCharacteristic = null;
|
||||||
_deviceDisplayName = null;
|
// Preserve deviceId and displayName for UI display during reconnection
|
||||||
_deviceId = null;
|
// They're only cleared on manual disconnect via disconnect() method
|
||||||
_maxContacts = _defaultMaxContacts;
|
_maxContacts = _defaultMaxContacts;
|
||||||
_maxChannels = _defaultMaxChannels;
|
_maxChannels = _defaultMaxChannels;
|
||||||
_isSyncingQueuedMessages = false;
|
_isSyncingQueuedMessages = false;
|
||||||
|
|||||||
@@ -344,6 +344,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||||||
final connector = context.read<MeshCoreConnector>();
|
final connector = context.read<MeshCoreConnector>();
|
||||||
final isOwnNode = message.replyToSenderName == connector.selfName;
|
final isOwnNode = message.replyToSenderName == connector.selfName;
|
||||||
final replyText = message.replyToText ?? '';
|
final replyText = message.replyToText ?? '';
|
||||||
|
final colorScheme = Theme.of(context).colorScheme;
|
||||||
|
final previewTextColor = colorScheme.onSurface.withValues(alpha: 0.7);
|
||||||
|
|
||||||
final gifId = _parseGifId(replyText);
|
final gifId = _parseGifId(replyText);
|
||||||
final poi = _parsePoiMessage(replyText);
|
final poi = _parsePoiMessage(replyText);
|
||||||
@@ -352,17 +354,17 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||||||
if (gifId != null) {
|
if (gifId != null) {
|
||||||
contentPreview = Row(
|
contentPreview = Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.gif_box, size: 14, color: Colors.grey[600]),
|
Icon(Icons.gif_box, size: 14, color: previewTextColor),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text('GIF', style: TextStyle(fontSize: 12, color: Colors.grey[700])),
|
Text('GIF', style: TextStyle(fontSize: 12, color: previewTextColor)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else if (poi != null) {
|
} else if (poi != null) {
|
||||||
contentPreview = Row(
|
contentPreview = Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.location_on_outlined, size: 14, color: Colors.grey[600]),
|
Icon(Icons.location_on_outlined, size: 14, color: previewTextColor),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
Text('Location', style: TextStyle(fontSize: 12, color: Colors.grey[700])),
|
Text('Location', style: TextStyle(fontSize: 12, color: previewTextColor)),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@@ -372,7 +374,7 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: Colors.grey[700],
|
color: previewTextColor,
|
||||||
fontStyle: FontStyle.italic,
|
fontStyle: FontStyle.italic,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -383,11 +385,11 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.black.withValues(alpha: 0.05),
|
color: colorScheme.surfaceContainerHighest.withValues(alpha: 0.5),
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border(
|
border: Border(
|
||||||
left: BorderSide(
|
left: BorderSide(
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: colorScheme.primary,
|
||||||
width: 3,
|
width: 3,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user