fix(ui): Add null check for cleanupBtn to prevent JS errors on main page

The cleanupBtn element only exists on the contact management page,
not on the main chat page. This was causing JavaScript to crash
with 'cannot access property addEventListener of null' error,
preventing messages from loading.

Added null check before attaching event listener.
This commit is contained in:
MarekWo
2025-12-30 09:21:30 +01:00
parent c51a38aa1f
commit 72605aed21

View File

@@ -99,10 +99,13 @@ function setupEventListeners() {
}
});
// Cleanup contacts button
document.getElementById('cleanupBtn').addEventListener('click', function() {
cleanupContacts();
});
// Cleanup contacts button (only exists on contact management page)
const cleanupBtn = document.getElementById('cleanupBtn');
if (cleanupBtn) {
cleanupBtn.addEventListener('click', function() {
cleanupContacts();
});
}
// Track user scrolling
const container = document.getElementById('messagesContainer');