fix(messages): fix currentConversationIdId → currentConversationId typo
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

A previous replace-all of 'currentConversation' → 'currentConversationId'
doubled the suffix on the existing 'currentConversationId' variable,
breaking all conversation state references including the group panel.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-04-08 16:54:47 +02:00
parent a57e21b538
commit e4457656d8
2 changed files with 49 additions and 49 deletions

View File

@ -188,7 +188,7 @@
renderItem: function (conv) { renderItem: function (conv) {
var item = el('div', 'conversation-item'); var item = el('div', 'conversation-item');
item.dataset.id = conv.id; item.dataset.id = conv.id;
if (conv.id === state.currentConversationIdId) item.classList.add('active'); if (conv.id === state.currentConversationId) item.classList.add('active');
if (conv.unread_count > 0) item.classList.add('unread'); if (conv.unread_count > 0) item.classList.add('unread');
// Avatar // Avatar
@ -262,7 +262,7 @@
}, },
selectConversation: function (id) { selectConversation: function (id) {
state.currentConversationIdId = id; state.currentConversationId = id;
// Update active class // Update active class
document.querySelectorAll('.conversation-item').forEach(function (el) { document.querySelectorAll('.conversation-item').forEach(function (el) {
@ -514,7 +514,7 @@
// Sender name (groups, other people's messages) // Sender name (groups, other people's messages)
if (!isMine && msg.sender) { if (!isMine && msg.sender) {
var conv = state.conversations.find(function (c) { return c.id === state.currentConversationIdId; }); var conv = state.conversations.find(function (c) { return c.id === state.currentConversationId; });
if (conv && conv.is_group) { if (conv && conv.is_group) {
var senderName = el('div', 'message-subject', msg.sender.name); var senderName = el('div', 'message-subject', msg.sender.name);
bubble.appendChild(senderName); bubble.appendChild(senderName);
@ -636,7 +636,7 @@
var check = el('span', 'read-status'); var check = el('span', 'read-status');
// Check if other members have read this message // Check if other members have read this message
var details = state.conversationDetails[state.currentConversationIdId]; var details = state.conversationDetails[state.currentConversationId];
var isRead = false; var isRead = false;
var readAt = null; var readAt = null;
@ -663,7 +663,7 @@
var otherMembers = details.members.filter(function (m) { var otherMembers = details.members.filter(function (m) {
return m.user_id !== window.__CURRENT_USER__.id; return m.user_id !== window.__CURRENT_USER__.id;
}); });
var conv = state.conversations.find(function (c) { return c.id === state.currentConversationIdId; }); var conv = state.conversations.find(function (c) { return c.id === state.currentConversationId; });
var isGroup = conv && conv.is_group; var isGroup = conv && conv.is_group;
if (isGroup) { if (isGroup) {
@ -761,7 +761,7 @@
if (dominated) return; if (dominated) return;
state.messages[convId].push(msg); state.messages[convId].push(msg);
if (convId !== state.currentConversationIdId) return; if (convId !== state.currentConversationId) return;
var container = document.getElementById('chatMessages'); var container = document.getElementById('chatMessages');
if (!container) return; if (!container) return;
@ -1011,7 +1011,7 @@
list.style.overflowY = 'auto'; list.style.overflowY = 'auto';
state.conversations.forEach(function (conv) { state.conversations.forEach(function (conv) {
if (conv.id === state.currentConversationIdId) return; if (conv.id === state.currentConversationId) return;
var item = el('div', 'conversation-item'); var item = el('div', 'conversation-item');
item.style.cursor = 'pointer'; item.style.cursor = 'pointer';
@ -1064,7 +1064,7 @@
} catch (_) {} } catch (_) {}
} }
// Refresh pins // Refresh pins
ChatView.loadConversationDetails(state.currentConversationIdId); ChatView.loadConversationDetails(state.currentConversationId);
}, },
startEdit: function (msg) { startEdit: function (msg) {
@ -1122,7 +1122,7 @@
api('/api/messages/' + msg.id, 'PATCH', { content: newContent }) api('/api/messages/' + msg.id, 'PATCH', { content: newContent })
.then(function (updated) { .then(function (updated) {
// Update in state // Update in state
var msgs = state.messages[state.currentConversationIdId] || []; var msgs = state.messages[state.currentConversationId] || [];
var idx = msgs.findIndex(function (m) { return m.id === msg.id; }); var idx = msgs.findIndex(function (m) { return m.id === msg.id; });
if (idx !== -1) msgs[idx] = updated; if (idx !== -1) msgs[idx] = updated;
state.editingMessageId = null; state.editingMessageId = null;
@ -1136,7 +1136,7 @@
cancelBtn.addEventListener('click', function () { cancelBtn.addEventListener('click', function () {
state.editingMessageId = null; state.editingMessageId = null;
ChatView.renderMessages(state.messages[state.currentConversationIdId] || []); ChatView.renderMessages(state.messages[state.currentConversationId] || []);
ChatView.scrollToMessage(msg.id); ChatView.scrollToMessage(msg.id);
}); });
@ -1162,7 +1162,7 @@
api('/api/messages/' + msg.id, 'DELETE') api('/api/messages/' + msg.id, 'DELETE')
.then(function () { .then(function () {
// Update in state // Update in state
var msgs = state.messages[state.currentConversationIdId] || []; var msgs = state.messages[state.currentConversationId] || [];
var idx = msgs.findIndex(function (m) { return m.id === msg.id; }); var idx = msgs.findIndex(function (m) { return m.id === msg.id; });
if (idx !== -1) { if (idx !== -1) {
msgs[idx].is_deleted = true; msgs[idx].is_deleted = true;
@ -1207,7 +1207,7 @@
await api('/api/messages/' + messageId + '/reactions', 'POST', { emoji: emoji }); await api('/api/messages/' + messageId + '/reactions', 'POST', { emoji: emoji });
} }
// Refresh messages to update reactions display // Refresh messages to update reactions display
ChatView.loadMessages(state.currentConversationIdId); ChatView.loadMessages(state.currentConversationId);
} catch (e) { } catch (e) {
// silently ignore // silently ignore
} }
@ -1216,7 +1216,7 @@
addFromPicker: async function (messageId, emoji) { addFromPicker: async function (messageId, emoji) {
try { try {
await api('/api/messages/' + messageId + '/reactions', 'POST', { emoji: emoji }); await api('/api/messages/' + messageId + '/reactions', 'POST', { emoji: emoji });
ChatView.loadMessages(state.currentConversationIdId); ChatView.loadMessages(state.currentConversationId);
} catch (e) { } catch (e) {
// silently ignore // silently ignore
} }
@ -1363,11 +1363,11 @@
}, },
sendContent: function (html, text) { sendContent: function (html, text) {
if (!state.currentConversationIdId) return; if (!state.currentConversationId) return;
// Add to queue with current state snapshot // Add to queue with current state snapshot
var tempId = 'temp-' + Date.now() + '-' + Math.random(); var tempId = 'temp-' + Date.now() + '-' + Math.random();
Composer._sendQueue.push({ Composer._sendQueue.push({
convId: state.currentConversationIdId, convId: state.currentConversationId,
html: html, html: html,
text: text, text: text,
replyTo: state.replyToMessage, replyTo: state.replyToMessage,
@ -1382,7 +1382,7 @@
// Show optimistic message immediately // Show optimistic message immediately
ChatView.appendMessage({ ChatView.appendMessage({
id: tempId, id: tempId,
conversation_id: state.currentConversationIdId, conversation_id: state.currentConversationId,
content: html, content: html,
sender_id: window.__CURRENT_USER__ ? window.__CURRENT_USER__.id : null, sender_id: window.__CURRENT_USER__ ? window.__CURRENT_USER__.id : null,
sender: window.__CURRENT_USER__ || {}, sender: window.__CURRENT_USER__ || {},
@ -1405,7 +1405,7 @@
// send: called from button click — reads from Quill // send: called from button click — reads from Quill
send: async function () { send: async function () {
if (!state.currentConversationIdId || !state.quill) return; if (!state.currentConversationId || !state.quill) return;
var html = state.quill.root.innerHTML; var html = state.quill.root.innerHTML;
var text = state.quill.getText().trim(); var text = state.quill.getText().trim();
@ -1414,7 +1414,7 @@
if (!text && !hasImage && !state.attachedFiles.length) return; if (!text && !hasImage && !state.attachedFiles.length) return;
if (!text && hasImage) text = '📷'; if (!text && hasImage) text = '📷';
var convId = state.currentConversationIdId; var convId = state.currentConversationId;
var savedReplyTo = state.replyToMessage; var savedReplyTo = state.replyToMessage;
var savedFiles = state.attachedFiles.slice(); var savedFiles = state.attachedFiles.slice();
@ -1532,17 +1532,17 @@
}, },
sendTyping: function () { sendTyping: function () {
if (!state.currentConversationIdId) return; if (!state.currentConversationId) return;
if (state.typingTimeout) clearTimeout(state.typingTimeout); if (state.typingTimeout) clearTimeout(state.typingTimeout);
state.typingTimeout = setTimeout(function () { state.typingTimeout = setTimeout(function () {
api('/api/conversations/' + state.currentConversationIdId + '/typing', 'POST') api('/api/conversations/' + state.currentConversationId + '/typing', 'POST')
.catch(function () {}); .catch(function () {});
}, 300); }, 300);
// Debounce: only send after 300ms of no typing, then don't send again for 2s // Debounce: only send after 300ms of no typing, then don't send again for 2s
clearTimeout(state.typingTimeout); clearTimeout(state.typingTimeout);
if (!state._lastTypingSent || Date.now() - state._lastTypingSent > 2000) { if (!state._lastTypingSent || Date.now() - state._lastTypingSent > 2000) {
state._lastTypingSent = Date.now(); state._lastTypingSent = Date.now();
api('/api/conversations/' + state.currentConversationIdId + '/typing', 'POST') api('/api/conversations/' + state.currentConversationId + '/typing', 'POST')
.catch(function () {}); .catch(function () {});
} }
}, },
@ -1616,8 +1616,8 @@
state.sse.addEventListener('message_pinned', function (e) { state.sse.addEventListener('message_pinned', function (e) {
try { try {
var data = JSON.parse(e.data); var data = JSON.parse(e.data);
if (data.conversation_id === state.currentConversationIdId) { if (data.conversation_id === state.currentConversationId) {
ChatView.loadConversationDetails(state.currentConversationIdId); ChatView.loadConversationDetails(state.currentConversationId);
} }
} catch (_) {} } catch (_) {}
}); });
@ -1625,8 +1625,8 @@
state.sse.addEventListener('message_unpinned', function (e) { state.sse.addEventListener('message_unpinned', function (e) {
try { try {
var data = JSON.parse(e.data); var data = JSON.parse(e.data);
if (data.conversation_id === state.currentConversationIdId) { if (data.conversation_id === state.currentConversationId) {
ChatView.loadConversationDetails(state.currentConversationIdId); ChatView.loadConversationDetails(state.currentConversationId);
} }
} catch (_) {} } catch (_) {}
}); });
@ -1652,7 +1652,7 @@
var convId = msg.conversation_id; var convId = msg.conversation_id;
// Append to current view if active // Append to current view if active
if (convId === state.currentConversationIdId) { if (convId === state.currentConversationId) {
ChatView.appendMessage(msg); ChatView.appendMessage(msg);
// Mark read // Mark read
api('/api/conversations/' + convId + '/read', 'POST').catch(function () {}); api('/api/conversations/' + convId + '/read', 'POST').catch(function () {});
@ -1670,7 +1670,7 @@
created_at: msg.created_at, created_at: msg.created_at,
}, },
updated_at: msg.created_at, updated_at: msg.created_at,
unread_count: convId === state.currentConversationIdId unread_count: convId === state.currentConversationId
? 0 ? 0
: (conv.unread_count || 0) + 1, : (conv.unread_count || 0) + 1,
}); });
@ -1685,8 +1685,8 @@
handleMessageRead: function (data) { handleMessageRead: function (data) {
// Update read receipts if viewing the same conversation // Update read receipts if viewing the same conversation
if (data.conversation_id === state.currentConversationIdId) { if (data.conversation_id === state.currentConversationId) {
var details = state.conversationDetails[state.currentConversationIdId]; var details = state.conversationDetails[state.currentConversationId];
if (details && details.members) { if (details && details.members) {
var member = details.members.find(function (m) { return m.user_id === data.user_id; }); var member = details.members.find(function (m) { return m.user_id === data.user_id; });
if (member) { if (member) {
@ -1694,13 +1694,13 @@
} }
} }
// Re-render to update check marks // Re-render to update check marks
ChatView.renderMessages(state.messages[state.currentConversationIdId] || []); ChatView.renderMessages(state.messages[state.currentConversationId] || []);
} }
}, },
handleTyping: function (data) { handleTyping: function (data) {
var convId = data.conversation_id; var convId = data.conversation_id;
if (convId !== state.currentConversationIdId) return; if (convId !== state.currentConversationId) return;
var typingEl = document.getElementById('typingIndicator'); var typingEl = document.getElementById('typingIndicator');
var typingName = document.getElementById('typingName'); var typingName = document.getElementById('typingName');
@ -1732,14 +1732,14 @@
handleReaction: function (data) { handleReaction: function (data) {
var convId = data.conversation_id; var convId = data.conversation_id;
if (convId !== state.currentConversationIdId) return; if (convId !== state.currentConversationId) return;
// Reload messages to update reactions // Reload messages to update reactions
ChatView.loadMessages(convId); ChatView.loadMessages(convId);
}, },
handleMessageEdited: function (msg) { handleMessageEdited: function (msg) {
var convId = msg.conversation_id; var convId = msg.conversation_id;
if (convId !== state.currentConversationIdId) return; if (convId !== state.currentConversationId) return;
var msgs = state.messages[convId] || []; var msgs = state.messages[convId] || [];
var idx = msgs.findIndex(function (m) { return m.id === msg.id; }); var idx = msgs.findIndex(function (m) { return m.id === msg.id; });
if (idx !== -1) { if (idx !== -1) {
@ -1750,7 +1750,7 @@
handleMessageDeleted: function (data) { handleMessageDeleted: function (data) {
var convId = data.conversation_id; var convId = data.conversation_id;
if (convId !== state.currentConversationIdId) return; if (convId !== state.currentConversationId) return;
var msgs = state.messages[convId] || []; var msgs = state.messages[convId] || [];
var idx = msgs.findIndex(function (m) { return m.id === data.id; }); var idx = msgs.findIndex(function (m) { return m.id === data.id; });
if (idx !== -1) { if (idx !== -1) {
@ -1762,8 +1762,8 @@
handlePresence: function (data) { handlePresence: function (data) {
// Update online dot in header if relevant // Update online dot in header if relevant
if (!state.currentConversationIdId) return; if (!state.currentConversationId) return;
var details = state.conversationDetails[state.currentConversationIdId]; var details = state.conversationDetails[state.currentConversationId];
if (!details || !details.members) return; if (!details || !details.members) return;
var member = details.members.find(function (m) { return m.user_id === data.user_id; }); var member = details.members.find(function (m) { return m.user_id === data.user_id; });
@ -1793,8 +1793,8 @@
// Poll for new messages every 5 seconds when SSE is unavailable // Poll for new messages every 5 seconds when SSE is unavailable
if (state.pollingInterval) return; if (state.pollingInterval) return;
state.pollingInterval = setInterval(function () { state.pollingInterval = setInterval(function () {
if (!state.currentConversationIdId) return; if (!state.currentConversationId) return;
var convId = state.currentConversationIdId; var convId = state.currentConversationId;
var msgs = state.messages[convId]; var msgs = state.messages[convId];
if (!msgs || !msgs.length) return; if (!msgs || !msgs.length) return;
@ -1889,8 +1889,8 @@
startPolling: function () { startPolling: function () {
state.presenceInterval = setInterval(function () { state.presenceInterval = setInterval(function () {
if (state.currentConversationIdId) { if (state.currentConversationId) {
Presence.fetchForConversation(state.currentConversationIdId); Presence.fetchForConversation(state.currentConversationId);
} }
}, 60000); }, 60000);
}, },
@ -2912,9 +2912,9 @@
}, },
loadAndShow: async function () { loadAndShow: async function () {
if (!state.currentConversationIdId) return; if (!state.currentConversationId) return;
try { try {
var data = await api('/api/conversations/' + state.currentConversationIdId + '/pins'); var data = await api('/api/conversations/' + state.currentConversationId + '/pins');
// API returns array directly, not {pins: [...]} // API returns array directly, not {pins: [...]}
var pins = Array.isArray(data) ? data : (data.pins || []); var pins = Array.isArray(data) ? data : (data.pins || []);
@ -3036,16 +3036,16 @@
if (!chatMessages) return; if (!chatMessages) return;
chatMessages.addEventListener('scroll', function () { chatMessages.addEventListener('scroll', function () {
if (chatMessages.scrollTop < 100 && state.currentConversationIdId) { if (chatMessages.scrollTop < 100 && state.currentConversationId) {
var msgs = state.messages[state.currentConversationIdId] || []; var msgs = state.messages[state.currentConversationId] || [];
var hasMore = state.hasMore[state.currentConversationIdId]; var hasMore = state.hasMore[state.currentConversationId];
if (hasMore && msgs.length > 0) { if (hasMore && msgs.length > 0) {
var oldestId = msgs[0].id; var oldestId = msgs[0].id;
// Prevent multiple loads // Prevent multiple loads
state.hasMore[state.currentConversationIdId] = false; state.hasMore[state.currentConversationId] = false;
var scrollHeightBefore = chatMessages.scrollHeight; var scrollHeightBefore = chatMessages.scrollHeight;
ChatView.loadMessages(state.currentConversationIdId, oldestId).then(function () { ChatView.loadMessages(state.currentConversationId, oldestId).then(function () {
// Maintain scroll position // Maintain scroll position
var scrollHeightAfter = chatMessages.scrollHeight; var scrollHeightAfter = chatMessages.scrollHeight;
chatMessages.scrollTop = scrollHeightAfter - scrollHeightBefore; chatMessages.scrollTop = scrollHeightAfter - scrollHeightBefore;
@ -3065,7 +3065,7 @@
backBtn.addEventListener('click', function () { backBtn.addEventListener('click', function () {
var container = document.getElementById('conversationsApp'); var container = document.getElementById('conversationsApp');
if (container) container.classList.remove('show-chat'); if (container) container.classList.remove('show-chat');
state.currentConversationIdId = null; state.currentConversationId = null;
}); });
} }

View File

@ -326,7 +326,7 @@ window.__CSRF_TOKEN__ = '{{ csrf_token() }}';
// Load conversations.js after data is set // Load conversations.js after data is set
(function() { (function() {
var s = document.createElement('script'); var s = document.createElement('script');
s.src = '{{ url_for("static", filename="js/conversations.js") }}?v=23'; s.src = '{{ url_for("static", filename="js/conversations.js") }}?v=24';
document.body.appendChild(s); document.body.appendChild(s);
})(); })();
{% endblock %} {% endblock %}