Merge pull request #3000 from sigaloid/master

Add config setting to disable update check
This commit is contained in:
zadam 2022-07-20 00:05:34 +02:00 committed by GitHub
commit 0e41f9d1bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 8 deletions

View File

@ -1,6 +1,7 @@
import BasicWidget from "../basic_widget.js"; import BasicWidget from "../basic_widget.js";
import utils from "../../services/utils.js"; import utils from "../../services/utils.js";
import UpdateAvailableWidget from "./update_available.js"; import UpdateAvailableWidget from "./update_available.js";
import options from "../../services/options.js";
const TPL = ` const TPL = `
<div class="dropdown global-menu dropright"> <div class="dropdown global-menu dropright">
@ -156,6 +157,7 @@ export default class GlobalMenuWidget extends BasicWidget {
} }
async updateVersionStatus() { async updateVersionStatus() {
if (options.get("checkForUpdates") == 'true') {
const latestVersion = await this.fetchLatestVersion(); const latestVersion = await this.fetchLatestVersion();
this.updateAvailableWidget.updateVersionStatus(latestVersion); this.updateAvailableWidget.updateVersionStatus(latestVersion);
@ -163,6 +165,7 @@ export default class GlobalMenuWidget extends BasicWidget {
this.$updateToLatestVersionButton.toggle(latestVersion > glob.triliumVersion); this.$updateToLatestVersionButton.toggle(latestVersion > glob.triliumVersion);
this.$updateToLatestVersionButton.find(".version-text").text(`Version ${latestVersion} is available, click to download.`); this.$updateToLatestVersionButton.find(".version-text").text(`Version ${latestVersion} is available, click to download.`);
} }
}
async fetchLatestVersion() { async fetchLatestVersion() {
const RELEASES_API_URL = "https://api.github.com/repos/zadam/trilium/releases/latest"; const RELEASES_API_URL = "https://api.github.com/repos/zadam/trilium/releases/latest";

View File

@ -116,7 +116,17 @@ const TPL = `
<label for="auto-readonly-size-code">Automatic readonly size (code notes)</label> <label for="auto-readonly-size-code">Automatic readonly size (code notes)</label>
<input class="form-control" id="auto-readonly-size-code" type="number" min="0"> <input class="form-control" id="auto-readonly-size-code" type="number" min="0">
</div> </div>
</div>`; </div>
<div>
<h4>Network connections</h4>
<div class="form-group">
<input id="check-for-updates" type="checkbox" name="check-for-updates">
<label for="check-for-updates">Check for updates automatically</label>
</div>
</div>
`;
export default class ProtectedSessionOptions { export default class ProtectedSessionOptions {
constructor() { constructor() {
@ -142,7 +152,7 @@ export default class ProtectedSessionOptions {
this.$availableLanguageCodes = $("#available-language-codes"); this.$availableLanguageCodes = $("#available-language-codes");
if (utils.isElectron()) { if (utils.isElectron()) {
const {webContents} = utils.dynamicRequire('@electron/remote').getCurrentWindow(); const { webContents } = utils.dynamicRequire('@electron/remote').getCurrentWindow();
this.$availableLanguageCodes.text(webContents.session.availableSpellCheckerLanguages.join(', ')); this.$availableLanguageCodes.text(webContents.session.availableSpellCheckerLanguages.join(', '));
} }
@ -250,6 +260,14 @@ export default class ProtectedSessionOptions {
this.setImageCompression(isChecked); this.setImageCompression(isChecked);
}); });
this.$checkForUpdates = $("#check-for-updates");
this.$checkForUpdates.on("change", () => {
const isChecked = this.$checkForUpdates.prop("checked");
const opts = { 'checkForUpdates': isChecked ? 'true' : 'false' };
server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved."));
});
} }
optionsLoaded(options) { optionsLoaded(options) {
@ -272,5 +290,10 @@ export default class ProtectedSessionOptions {
const compressImages = options['compressImages'] === 'true'; const compressImages = options['compressImages'] === 'true';
this.$enableImageCompression.prop('checked', compressImages); this.$enableImageCompression.prop('checked', compressImages);
this.setImageCompression(compressImages); this.setImageCompression(compressImages);
const checkForUpdates = options['checkForUpdates'] === 'true';
this.$checkForUpdates.prop('checked', checkForUpdates);
} }
} }

View File

@ -57,7 +57,8 @@ const ALLOWED_OPTIONS = new Set([
'maxContentWidth', 'maxContentWidth',
'compressImages', 'compressImages',
'downloadImagesAutomatically', 'downloadImagesAutomatically',
'minTocHeadings' 'minTocHeadings',
'checkForUpdates'
]); ]);
function getOptions() { function getOptions() {

View File

@ -5,6 +5,7 @@ const optionService = require('../services/options');
const myScryptService = require('../services/my_scrypt'); const myScryptService = require('../services/my_scrypt');
const log = require('../services/log'); const log = require('../services/log');
const passwordService = require("../services/password"); const passwordService = require("../services/password");
const options = require('../services/options');
function loginPage(req, res) { function loginPage(req, res) {
res.render('login', { failedAuth: false }); res.render('login', { failedAuth: false });
@ -36,6 +37,7 @@ function setPassword(req, res) {
return; return;
} }
options.setOption("checkForUpdates", req.body['check-for-updates'] == 'on');
passwordService.setPassword(password1); passwordService.setPassword(password1);
res.redirect('login'); res.redirect('login');

View File

@ -85,7 +85,8 @@ const defaultOptions = [
{ name: 'maxContentWidth', value: '1200', isSynced: false }, { name: 'maxContentWidth', value: '1200', isSynced: false },
{ name: 'compressImages', value: 'true', isSynced: true }, { name: 'compressImages', value: 'true', isSynced: true },
{ name: 'downloadImagesAutomatically', value: 'true', isSynced: true }, { name: 'downloadImagesAutomatically', value: 'true', isSynced: true },
{ name: 'minTocHeadings', value: '5', isSynced: true } { name: 'minTocHeadings', value: '5', isSynced: true },
{ name: 'checkForUpdates', value: 'true', isSynced: true },
]; ];
function initStartupOptions() { function initStartupOptions() {

View File

@ -33,6 +33,11 @@
<input id="password" name="password2" placeholder="" class="form-control" type="password"> <input id="password" name="password2" placeholder="" class="form-control" type="password">
</div> </div>
</div> </div>
<div class="form-group">
<input checked id="check-for-updates" type="checkbox" name="check-for-updates">
<label for="check-for-updates">Check for updates automatically</label>
</div>
<div class="form-group"> <div class="form-group">
<button class="btn btn-success">Set password</button> <button class="btn btn-success">Set password</button>
</div> </div>