fix(messages): restore polling for own messages + content-based dedup for optimistic
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
This commit is contained in:
parent
8ac13f47b2
commit
406752fca2
@ -727,8 +727,22 @@
|
||||
if (!state.messages[convId]) state.messages[convId] = [];
|
||||
|
||||
// Dedup: skip if message with this ID already exists
|
||||
// Simple dedup by ID (string or number)
|
||||
if (msg.id && state.messages[convId].some(function(m) { return m.id === msg.id; })) return;
|
||||
// Dedup: by real ID or by matching optimistic message (same sender + content)
|
||||
var dominated = state.messages[convId].some(function(m) {
|
||||
if (m.id === msg.id) return true;
|
||||
// Match optimistic msg: same sender, same stripped content
|
||||
if (m._optimistic && msg.sender_id && m.sender_id === msg.sender_id) {
|
||||
var mc = (m.content || '').replace(/<[^>]*>/g, '').trim();
|
||||
var nc = (msg.content || '').replace(/<[^>]*>/g, '').trim();
|
||||
if (mc && nc && mc === nc) {
|
||||
m.id = msg.id; // Update to real ID
|
||||
m._optimistic = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
if (dominated) return;
|
||||
state.messages[convId].push(msg);
|
||||
|
||||
if (convId !== state.currentConversationId) return;
|
||||
@ -1714,12 +1728,8 @@
|
||||
if (!data.messages || !data.messages.length) return;
|
||||
|
||||
// Find messages newer than what we have
|
||||
var currentUserId = window.__CURRENT_USER__ ? window.__CURRENT_USER__.id : null;
|
||||
var newMsgs = data.messages.filter(function (msg) {
|
||||
if (msg.id <= newestId) return false;
|
||||
// Skip own messages — already displayed by optimistic UI
|
||||
if (currentUserId && msg.sender_id === currentUserId) return false;
|
||||
return true;
|
||||
return msg.id > newestId;
|
||||
});
|
||||
|
||||
if (newMsgs.length > 0) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user