fix: resolve Settings modal version display timing issue

- Make switchTab function async to handle proper timing
- Move loadCurrentVersion call to after DOM element creation
- Remove redundant version loading from loadConfiguration
- Ensures "Current Version" shows actual version instead of "Loading..."

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
rcourtman
2025-06-13 16:11:29 +01:00
parent 43110a8f91
commit 4512a5b75a
+9 -7
View File
@@ -58,15 +58,15 @@ PulseApp.ui.settings = (() => {
const tabButtons = document.querySelectorAll('.settings-tab');
tabButtons.forEach(button => {
button.addEventListener('click', (e) => {
button.addEventListener('click', async (e) => {
e.preventDefault();
const tabName = e.currentTarget.getAttribute('data-tab');
switchTab(tabName);
await switchTab(tabName);
});
});
}
function switchTab(tabName) {
async function switchTab(tabName) {
// Preserve current form data before switching tabs
preserveCurrentFormData();
@@ -91,6 +91,11 @@ PulseApp.ui.settings = (() => {
// Update content
renderTabContent();
// Load current version if system tab is active (after DOM element exists)
if (activeTab === 'system') {
await loadCurrentVersion();
}
// Restore form data for the new tab
restoreFormData();
}
@@ -107,7 +112,7 @@ PulseApp.ui.settings = (() => {
await loadConfiguration();
// Switch to requested tab
switchTab(tabName);
await switchTab(tabName);
}
function closeModal() {
@@ -126,9 +131,6 @@ PulseApp.ui.settings = (() => {
const data = await PulseApp.apiClient.get('/api/config');
currentConfig = data;
renderTabContent();
// Load current version from dynamic API
await loadCurrentVersion();
} catch (error) {
PulseApp.apiClient.handleError(error, 'Load configuration', showMessage);
}