fix: fetch version from API on init instead of using hardcoded value
The version was stuck at "1.0.0" because fetchVersion() was only called when initialLoad was true, but loadFromCache() set initialLoad to false before fetchData() ran. Now version is fetched unconditionally in the global store's init(). Fixes #144 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -125,11 +125,6 @@ document.addEventListener('alpine:init', () => {
|
|||||||
this.computeQuotaRows();
|
this.computeQuotaRows();
|
||||||
|
|
||||||
this.lastUpdated = new Date().toLocaleTimeString();
|
this.lastUpdated = new Date().toLocaleTimeString();
|
||||||
|
|
||||||
// Fetch version from config endpoint if not already loaded
|
|
||||||
if (this.initialLoad) {
|
|
||||||
this.fetchVersion(password);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Fetch error:', error);
|
console.error('Fetch error:', error);
|
||||||
const store = Alpine.store('global');
|
const store = Alpine.store('global');
|
||||||
@@ -140,20 +135,6 @@ document.addEventListener('alpine:init', () => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchVersion(password) {
|
|
||||||
try {
|
|
||||||
const { response } = await window.utils.request('/api/config', {}, password);
|
|
||||||
if (response.ok) {
|
|
||||||
const data = await response.json();
|
|
||||||
if (data.version) {
|
|
||||||
Alpine.store('global').version = data.version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('Failed to fetch version:', error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
async performHealthCheck() {
|
async performHealthCheck() {
|
||||||
try {
|
try {
|
||||||
// Get password from global store
|
// Get password from global store
|
||||||
|
|||||||
@@ -30,6 +30,23 @@ document.addEventListener('alpine:init', () => {
|
|||||||
this.activeTab = hash;
|
this.activeTab = hash;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 4. Fetch version from API
|
||||||
|
this.fetchVersion();
|
||||||
|
},
|
||||||
|
|
||||||
|
async fetchVersion() {
|
||||||
|
try {
|
||||||
|
const response = await fetch('/api/config');
|
||||||
|
if (response.ok) {
|
||||||
|
const data = await response.json();
|
||||||
|
if (data.version) {
|
||||||
|
this.version = data.version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.debug('Could not fetch version:', error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// App State
|
// App State
|
||||||
|
|||||||
Reference in New Issue
Block a user