fix loading version-info to use older edit api
This commit is contained in:
@@ -3696,45 +3696,41 @@ function checkVersionUpgrade(info) {
|
|||||||
versionCheckDone = true;
|
versionCheckDone = true;
|
||||||
|
|
||||||
// Fetch version-info.json using existing /edit endpoint
|
// Fetch version-info.json using existing /edit endpoint
|
||||||
fetch('/edit?edit=version-info.json', {
|
fetch('/edit?edit=/version-info.json', {
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.status === 404) {
|
if (res.status === 404) {
|
||||||
// File doesn't exist - first install, show install prompt
|
// File doesn't exist - first install, show install prompt
|
||||||
showVersionUpgradePrompt(info, null, info.ver);
|
showVersionUpgradePrompt(info, null, info.ver);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
throw new Error('Failed to fetch version-info.json');
|
throw new Error('Failed to fetch version-info.json');
|
||||||
}
|
}
|
||||||
return res.json();
|
return res.json();
|
||||||
})
|
})
|
||||||
.then(versionInfo => {
|
.then(versionInfo => {
|
||||||
if (!versionInfo) return; // 404 case already handled
|
if (!versionInfo) return; // 404 case already handled
|
||||||
|
|
||||||
// Check if user opted out
|
// Check if user opted out
|
||||||
if (versionInfo.neverAsk) return;
|
if (versionInfo.neverAsk) return;
|
||||||
|
|
||||||
// Check if version has changed
|
// Check if version has changed
|
||||||
const currentVersion = info.ver;
|
const currentVersion = info.ver;
|
||||||
const storedVersion = versionInfo.version || '';
|
const storedVersion = versionInfo.version || '';
|
||||||
|
|
||||||
if (storedVersion && storedVersion !== currentVersion) {
|
if (storedVersion && storedVersion !== currentVersion) {
|
||||||
// Version has changed, show upgrade prompt
|
// Version has changed, show upgrade prompt
|
||||||
showVersionUpgradePrompt(info, storedVersion, currentVersion);
|
showVersionUpgradePrompt(info, storedVersion, currentVersion);
|
||||||
} else if (!storedVersion) {
|
} else if (!storedVersion) {
|
||||||
// Empty version in file, show install prompt
|
// Empty version in file, show install prompt
|
||||||
showVersionUpgradePrompt(info, null, currentVersion);
|
showVersionUpgradePrompt(info, null, currentVersion);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
console.log('Failed to load version-info.json', e);
|
console.log('Failed to load version-info.json', e);
|
||||||
// On error, save current version for next time
|
});
|
||||||
if (info && info.ver) {
|
|
||||||
updateVersionInfo(info.ver, false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showVersionUpgradePrompt(info, oldVersion, newVersion) {
|
function showVersionUpgradePrompt(info, oldVersion, newVersion) {
|
||||||
|
|||||||
Reference in New Issue
Block a user