mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 08:20:36 +00:00
fix: Keep received replays separate
This commit is contained in:
@@ -664,6 +664,11 @@ class MessagesProvider with ChangeNotifier {
|
||||
return; // Skip duplicate
|
||||
}
|
||||
|
||||
final matchingSentReplayIndex = _findMatchingSentReplayIndex(finalMessage);
|
||||
if (matchingSentReplayIndex != -1) {
|
||||
_clearChannelSendWarning(_messages[matchingSentReplayIndex].id);
|
||||
}
|
||||
|
||||
_messages.add(finalMessage);
|
||||
if (contactLocationSnapshot != null) {
|
||||
_messageContactLocations[finalMessage.id] = contactLocationSnapshot;
|
||||
@@ -712,7 +717,8 @@ class MessagesProvider with ChangeNotifier {
|
||||
|
||||
for (int index = 0; index < _messages.length; index++) {
|
||||
final existing = _messages[index];
|
||||
if (!_matchesDuplicateScope(existing, message) ||
|
||||
if (existing.isSentMessage ||
|
||||
!_matchesDuplicateScope(existing, message) ||
|
||||
existing.text != message.text) {
|
||||
continue;
|
||||
}
|
||||
@@ -790,6 +796,27 @@ class MessagesProvider with ChangeNotifier {
|
||||
existingSenderName == incomingSenderName;
|
||||
}
|
||||
|
||||
int _findMatchingSentReplayIndex(Message message) {
|
||||
if (!message.isChannelMessage || message.isSentMessage) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int index = 0; index < _messages.length; index++) {
|
||||
final existing = _messages[index];
|
||||
if (!existing.isSentMessage ||
|
||||
!existing.isChannelMessage ||
|
||||
existing.text != message.text) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_matchesDuplicateScope(existing, message)) {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// Add multiple messages
|
||||
void addMessages(List<Message> messages) {
|
||||
int addedCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user