forked from snxraven/LinkUp-P2P-Chat
Prevent Message Duplicates in Message History
This commit is contained in:
parent
7a31202ac3
commit
98aa79f075
14
app.js
14
app.js
@ -768,7 +768,19 @@ function addMessageToStore(topic, messageObj) {
|
||||
if (!messagesStore[topic]) {
|
||||
messagesStore[topic] = [];
|
||||
}
|
||||
messagesStore[topic].push(messageObj);
|
||||
|
||||
// Check for duplicates
|
||||
const isDuplicate = messagesStore[topic].some(msg =>
|
||||
msg.from === messageObj.from &&
|
||||
msg.message === messageObj.message &&
|
||||
msg.timestamp === messageObj.timestamp
|
||||
);
|
||||
|
||||
if (!isDuplicate) {
|
||||
messagesStore[topic].push(messageObj);
|
||||
} else {
|
||||
console.log('Duplicate message detected:', messageObj); // Debugging log
|
||||
}
|
||||
}
|
||||
|
||||
function loadConfigFromFile() {
|
||||
|
Loading…
Reference in New Issue
Block a user