fix flicker after logout
This commit is contained in:
@@ -1286,30 +1286,39 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
function showMainContent() {
|
||||
if (!elements.loginPage || !elements.mainContent) {
|
||||
console.error('Required elements not found:', {
|
||||
loginPage: elements.loginPage,
|
||||
mainContent: elements.mainContent
|
||||
});
|
||||
showNotification('Page error: Essential elements missing. Please refresh the page.', 'error', 'page-error');
|
||||
return;
|
||||
// Check if apiKey exists in localStorage
|
||||
const apiKey = localStorage.getItem('apiKey');
|
||||
if (!apiKey) {
|
||||
console.error('API key not found in localStorage');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!elements.loginPage || !elements.mainContent) {
|
||||
console.error('Required elements not found:', {
|
||||
loginPage: elements.loginPage,
|
||||
mainContent: elements.mainContent
|
||||
});
|
||||
showNotification('Page error: Essential elements missing. Please refresh the page.', 'error', 'page-error');
|
||||
return;
|
||||
}
|
||||
|
||||
elements.loginPage.classList.add('hidden');
|
||||
elements.mainContent.classList.remove('hidden');
|
||||
|
||||
// Verify buttons exist
|
||||
const logoutBtn = document.getElementById('logoutBtn');
|
||||
const mobileLogoutBtn = document.getElementById('mobileLogoutBtn');
|
||||
|
||||
if (logoutBtn) {
|
||||
console.log('Desktop logout button found');
|
||||
console.log('Desktop logout button found');
|
||||
} else {
|
||||
console.error('Desktop logout button (#logoutBtn) not found');
|
||||
console.error('Desktop logout button (#logoutBtn) not found');
|
||||
}
|
||||
|
||||
if (mobileLogoutBtn) {
|
||||
console.log('Mobile logout button found');
|
||||
console.log('Mobile logout button found');
|
||||
} else {
|
||||
console.error('Mobile logout button (#mobileLogoutBtn) not found');
|
||||
console.error('Mobile logout button (#mobileLogoutBtn) not found');
|
||||
}
|
||||
|
||||
// Remove any existing logout listeners to prevent duplicates
|
||||
@@ -1317,17 +1326,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
// Event delegation for logout buttons
|
||||
function handleLogoutClick(event) {
|
||||
if (event.target.id === 'logoutBtn' || event.target.id === 'mobileLogoutBtn') {
|
||||
console.log(`Logout button clicked: ${event.target.id}`);
|
||||
handleLogout();
|
||||
}
|
||||
if (event.target.id === 'logoutBtn' || event.target.id === 'mobileLogoutBtn') {
|
||||
console.log(`Logout button clicked: ${event.target.id}`);
|
||||
handleLogout();
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('click', handleLogoutClick);
|
||||
|
||||
initializeCharts();
|
||||
initializeTerminal();
|
||||
}
|
||||
}
|
||||
|
||||
function handleApiKeyChange(e) {
|
||||
apiKey = e.target.value.trim();
|
||||
|
Reference in New Issue
Block a user