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