fix(messages): remove tempId reference in _doSend, use content matching, no alert
Some checks failed
NordaBiz Tests / Unit & Integration Tests (push) Has been cancelled
NordaBiz Tests / E2E Tests (Playwright) (push) Has been cancelled
NordaBiz Tests / Smoke Tests (Production) (push) Has been cancelled
NordaBiz Tests / Send Failure Notification (push) Has been cancelled

This commit is contained in:
Maciej Pienczyn 2026-03-28 17:48:00 +01:00
parent 406752fca2
commit 77f5277372

View File

@ -1368,13 +1368,18 @@
var result = await api('/api/conversations/' + convId + '/messages', 'POST', fd); var result = await api('/api/conversations/' + convId + '/messages', 'POST', fd);
// Replace temp ID with real ID in state so polling dedup works // Update optimistic message in state with real data (for dedup)
var msgs = state.messages[convId]; var msgs = state.messages[convId];
if (msgs) { if (msgs) {
var stripped = (html || '').replace(/<[^>]*>/g, '').trim();
for (var i = msgs.length - 1; i >= 0; i--) { for (var i = msgs.length - 1; i >= 0; i--) {
if (msgs[i].id === tempId) { if (msgs[i]._optimistic && msgs[i].sender_id === result.sender_id) {
msgs[i] = result; var mc = (msgs[i].content || '').replace(/<[^>]*>/g, '').trim();
break; if (mc === stripped) {
msgs[i].id = result.id;
msgs[i]._optimistic = false;
break;
}
} }
} }
} }
@ -1390,9 +1395,7 @@
updated_at: result.created_at, updated_at: result.created_at,
}); });
} catch (e) { } catch (e) {
alert('Nie udało się wysłać wiadomości: ' + e.message); console.error('Nie udało się wysłać wiadomości:', e.message);
} finally {
state._isSending = false;
} }
}, },