Skip to content

Commit 6cc0410

Browse files
committed
Add consent prompt for app update checks
Introduces a user prompt to enable app update checks, defaulting the setting to disabled. The prompt appears only once and updates the setting if the user consents, improving user control over update checks.
1 parent 36567bd commit 6cc0410

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/lib/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class Settings {
149149
lineHeight: 2,
150150
leftMargin: 50,
151151
checkFiles: true,
152-
checkForAppUpdates: true,
152+
checkForAppUpdates: false,
153153
desktopMode: false,
154154
console: this.CONSOLE_LEGACY,
155155
keyboardMode: this.KEYBOARD_MODE_NO_SUGGESTIONS_AGGRESSIVE,

src/main.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { TerminalManager } from "components/terminal";
2222
import tile from "components/tile";
2323
import toast from "components/toast";
2424
import tutorial from "components/tutorial";
25+
import confirm from "dialogs/confirm";
2526
import intentHandler, { processPendingIntents } from "handlers/intent";
2627
import keyboardHandler, { keydownState } from "handlers/keyboard";
2728
import quickToolsInit from "handlers/quickToolsInit";
@@ -259,8 +260,10 @@ async function onDeviceReady() {
259260
}, 500);
260261
}
261262

263+
await promptUpdateCheckConsent();
264+
262265
// Check for app updates
263-
if (settings.value.checkForUpdates && navigator.onLine) {
266+
if (settings.value.checkForAppUpdates && navigator.onLine) {
264267
cordova.plugin.http.sendRequest(
265268
"https://api.github.com/repos/Acode-Foundation/Acode/releases/latest",
266269
{
@@ -317,6 +320,27 @@ async function onDeviceReady() {
317320
.catch(console.error);
318321
}
319322

323+
async function promptUpdateCheckConsent() {
324+
try {
325+
if (Boolean(localStorage.getItem("checkForUpdatesPrompted"))) return;
326+
327+
if (settings.value.checkForAppUpdates) {
328+
localStorage.setItem("checkForUpdatesPrompted", "true");
329+
return;
330+
}
331+
332+
const message =
333+
"Acode can check for new app updates when you're online. Enable update checks?";
334+
const shouldEnable = await confirm(strings?.confirm, message);
335+
localStorage.setItem("checkForUpdatesPrompted", "true");
336+
if (shouldEnable) {
337+
await settings.update({ checkForAppUpdates: true }, false);
338+
}
339+
} catch (error) {
340+
console.error("Failed to prompt for update check consent", error);
341+
}
342+
}
343+
320344
async function loadApp() {
321345
let $mainMenu;
322346
let $fileMenu;

0 commit comments

Comments
 (0)