mirror of
https://github.com/wled/WLED.git
synced 2025-12-23 16:39:45 +00:00
Compare commits
3 Commits
rotate-zoo
...
copilot/up
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ca8ed65e8 | ||
|
|
6a2b7995e9 | ||
|
|
247a7a51d7 |
@@ -3343,8 +3343,14 @@ function checkVersionUpgrade(info) {
|
||||
const storedVersion = versionInfo.version || '';
|
||||
|
||||
if (storedVersion && storedVersion !== currentVersion) {
|
||||
// Version has changed, show upgrade prompt
|
||||
showVersionUpgradePrompt(info, storedVersion, currentVersion);
|
||||
// Version has changed
|
||||
if (versionInfo.alwaysReport) {
|
||||
// Automatically report if user opted in for always reporting
|
||||
reportUpgradeEvent(info, storedVersion);
|
||||
} else {
|
||||
// Show upgrade prompt
|
||||
showVersionUpgradePrompt(info, storedVersion, currentVersion);
|
||||
}
|
||||
} else if (!storedVersion) {
|
||||
// Empty version in file, show install prompt
|
||||
showVersionUpgradePrompt(info, null, currentVersion);
|
||||
@@ -3354,7 +3360,7 @@ function checkVersionUpgrade(info) {
|
||||
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);
|
||||
updateVersionInfo(info.ver, false, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -3380,7 +3386,7 @@ function showVersionUpgradePrompt(info, oldVersion, newVersion) {
|
||||
? `You are now running WLED <strong style="text-wrap: nowrap">${newVersion}</strong>.`
|
||||
: `Your WLED has been upgraded from <strong style="text-wrap: nowrap">${oldVersion}</strong> to <strong style="text-wrap: nowrap">${newVersion}</strong>.`;
|
||||
|
||||
const question = 'Help make WLED better with a one-time hardware report? It includes only device details like chip type, LED count, etc. — never personal data or your activities.'
|
||||
const question = 'Help make WLED better by sharing hardware details like chip type and LED count? This helps us understand how WLED is used and prioritize features — we never collect personal data or your activities.'
|
||||
|
||||
dialog.innerHTML = `
|
||||
<h2 style="margin-top:0;color:var(--c-f);">${title}</h2>
|
||||
@@ -3389,8 +3395,9 @@ function showVersionUpgradePrompt(info, oldVersion, newVersion) {
|
||||
<p style="color:var(--c-f);font-size:0.9em;">
|
||||
<a href="https://kno.wled.ge/about/privacy-policy/" target="_blank" style="color:var(--c-6);">Learn more about what data is collected and why</a>
|
||||
</p>
|
||||
<div style="margin-top:20px;">
|
||||
<div style="margin-top:20px;display:flex;flex-wrap:wrap;gap:8px;">
|
||||
<button id="versionReportYes" class="btn">Yes</button>
|
||||
<button id="versionReportAlways" class="btn">Yes, Always</button>
|
||||
<button id="versionReportNo" class="btn">Not Now</button>
|
||||
<button id="versionReportNever" class="btn">Never Ask</button>
|
||||
</div>
|
||||
@@ -3405,19 +3412,25 @@ function showVersionUpgradePrompt(info, oldVersion, newVersion) {
|
||||
d.body.removeChild(overlay);
|
||||
});
|
||||
|
||||
gId('versionReportAlways').addEventListener('click', () => {
|
||||
reportUpgradeEvent(info, oldVersion, true); // Pass true for alwaysReport
|
||||
d.body.removeChild(overlay);
|
||||
showToast('Thank you! Future upgrades will be reported automatically.');
|
||||
});
|
||||
|
||||
gId('versionReportNo').addEventListener('click', () => {
|
||||
// Don't update version, will ask again on next load
|
||||
d.body.removeChild(overlay);
|
||||
});
|
||||
|
||||
gId('versionReportNever').addEventListener('click', () => {
|
||||
updateVersionInfo(newVersion, true);
|
||||
updateVersionInfo(newVersion, true, false);
|
||||
d.body.removeChild(overlay);
|
||||
showToast('You will not be asked again.');
|
||||
});
|
||||
}
|
||||
|
||||
function reportUpgradeEvent(info, oldVersion) {
|
||||
function reportUpgradeEvent(info, oldVersion, alwaysReport) {
|
||||
showToast('Reporting upgrade...');
|
||||
|
||||
// Fetch fresh data from /json/info endpoint as requested
|
||||
@@ -3458,7 +3471,7 @@ function reportUpgradeEvent(info, oldVersion) {
|
||||
.then(res => {
|
||||
if (res.ok) {
|
||||
showToast('Thank you for reporting!');
|
||||
updateVersionInfo(info.ver, false);
|
||||
updateVersionInfo(info.ver, false, !!alwaysReport);
|
||||
} else {
|
||||
showToast('Report failed. Please try again later.', true);
|
||||
// Do NOT update version info on failure - user will be prompted again
|
||||
@@ -3471,10 +3484,11 @@ function reportUpgradeEvent(info, oldVersion) {
|
||||
});
|
||||
}
|
||||
|
||||
function updateVersionInfo(version, neverAsk) {
|
||||
function updateVersionInfo(version, neverAsk, alwaysReport) {
|
||||
const versionInfo = {
|
||||
version: version,
|
||||
neverAsk: neverAsk
|
||||
neverAsk: neverAsk,
|
||||
alwaysReport: !!alwaysReport
|
||||
};
|
||||
|
||||
// Create a Blob with JSON content and use /upload endpoint
|
||||
|
||||
Reference in New Issue
Block a user