Skip to content

Commit fe56a20

Browse files
authored
setting: Add an option to disable the auto-updates. (#493)
Fixes: #491.
1 parent cfc97c9 commit fe56a20

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

app/main/autoupdater.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ function appUpdater(updateFromMenu = false) {
3030
autoUpdater.logger = log;
3131

3232
// Handle auto updates for beta/pre releases
33-
autoUpdater.allowPrerelease = ConfigUtil.getConfigItem('betaUpdate') || false;
33+
const isBetaUpdate = ConfigUtil.getConfigItem('betaUpdate');
34+
35+
autoUpdater.allowPrerelease = isBetaUpdate || false;
3436

3537
const eventsListenerRemove = ['update-available', 'update-not-available'];
3638
autoUpdater.on('update-available', info => {

app/main/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ app.on('ready', () => {
161161

162162
page.once('did-frame-finish-load', () => {
163163
// Initate auto-updates on MacOS and Windows
164-
appUpdater();
164+
if (ConfigUtil.getConfigItem('autoUpdate')) {
165+
appUpdater();
166+
}
165167
crashHandler();
166168
});
167169

app/renderer/js/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class ServerManagerView {
8989
startMinimized: false,
9090
enableSpellchecker: true,
9191
showNotification: true,
92+
autoUpdate: true,
9293
betaUpdate: false,
9394
silent: false,
9495
lastActiveTab: 0,

app/renderer/js/pages/preference/general-section.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ class GeneralSection extends BaseSection {
4848
</div>
4949
</div>
5050
<div class="title">App Updates</div>
51-
<div class="settings-card">
51+
<div class="settings-card">
52+
<div class="setting-row" id="autoupdate-option">
53+
<div class="setting-description">Enable auto updates</div>
54+
<div class="setting-control"></div>
55+
</div>
5256
<div class="setting-row" id="betaupdate-option">
5357
<div class="setting-description">Get beta updates</div>
5458
<div class="setting-control"></div>
@@ -104,7 +108,8 @@ class GeneralSection extends BaseSection {
104108
this.updateTrayOption();
105109
this.updateBadgeOption();
106110
this.updateSilentOption();
107-
this.updateUpdateOption();
111+
this.autoUpdateOption();
112+
this.betaUpdateOption();
108113
this.updateSidebarOption();
109114
this.updateStartAtLoginOption();
110115
this.updateResetDataOption();
@@ -160,14 +165,26 @@ class GeneralSection extends BaseSection {
160165
});
161166
}
162167

163-
updateUpdateOption() {
168+
autoUpdateOption() {
169+
this.generateSettingOption({
170+
$element: document.querySelector('#autoupdate-option .setting-control'),
171+
value: ConfigUtil.getConfigItem('autoUpdate', true),
172+
clickHandler: () => {
173+
const newValue = !ConfigUtil.getConfigItem('autoUpdate');
174+
ConfigUtil.setConfigItem('autoUpdate', newValue);
175+
this.autoUpdateOption();
176+
}
177+
});
178+
}
179+
180+
betaUpdateOption() {
164181
this.generateSettingOption({
165182
$element: document.querySelector('#betaupdate-option .setting-control'),
166183
value: ConfigUtil.getConfigItem('betaUpdate', false),
167184
clickHandler: () => {
168185
const newValue = !ConfigUtil.getConfigItem('betaUpdate');
169186
ConfigUtil.setConfigItem('betaUpdate', newValue);
170-
this.updateUpdateOption();
187+
this.betaUpdateOption();
171188
}
172189
});
173190
}

0 commit comments

Comments
 (0)