Skip to content

Commit

Permalink
Update checker isUpdateCheckerAllowed -> isUpdateCheckerAllowed
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Jun 1, 2024
1 parent 4e70bee commit a4d32dc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src-main/update-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ const privilegedFetch = require('./fetch');
const currentVersion = packageJSON.version;
const URL = 'https://desktop.turbowarp.org/version.json';

const isEnabledAtBuildTime = () => !!packageJSON.tw_update;
/**
* Determines whether the update checker is even allowed to be enabled
* in this build of the app.
* @returns {boolean}
*/
const isUpdateCheckerAllowed = () => {
// Must be enabled in package.json
return !!packageJSON.tw_update;
};

const checkForUpdates = async () => {
if (!isEnabledAtBuildTime() || settings.updateChecker === 'never') {
if (!isUpdateCheckerAllowed() || settings.updateChecker === 'never') {
return;
}

Expand Down Expand Up @@ -57,7 +65,7 @@ const ignoreUpdate = async (version, until) => {
};

module.exports = {
isEnabledAtBuildTime,
isUpdateCheckerAllowed,
checkForUpdates,
ignoreUpdate
};
4 changes: 2 additions & 2 deletions src-main/windows/desktop-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const AbstractWindow = require('./abstract');
const {translate, getStrings, getLocale} = require('../l10n');
const {APP_NAME} = require('../brand');
const settings = require('../settings');
const {isEnabledAtBuildTime} = require('../update-checker');
const {isUpdateCheckerAllowed} = require('../update-checker');
const RichPresence = require('../rich-presence');

class DesktopSettingsWindow extends AbstractWindow {
Expand All @@ -25,7 +25,7 @@ class DesktopSettingsWindow extends AbstractWindow {

ipc.on('get-settings', (event) => {
event.returnValue = {
updateCheckerAllowed: isEnabledAtBuildTime(),
updateCheckerAllowed: isUpdateCheckerAllowed(),
updateChecker: settings.updateChecker,
microphone: settings.microphone,
camera: settings.camera,
Expand Down
4 changes: 2 additions & 2 deletions src-main/windows/privacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const AbstractWindow = require('./abstract');
const DesktopSettingsWindow = require('./desktop-settings');
const {translate} = require('../l10n');
const {APP_NAME} = require('../brand');
const {isEnabledAtBuildTime} = require('../update-checker');
const {isUpdateCheckerAllowed} = require('../update-checker');

class PrivacyWindow extends AbstractWindow {
constructor () {
Expand All @@ -11,7 +11,7 @@ class PrivacyWindow extends AbstractWindow {
const ipc = this.window.webContents.ipc;

ipc.on('is-update-checker-allowed', (e) => {
e.returnValue = isEnabledAtBuildTime();
e.returnValue = isUpdateCheckerAllowed();
});

ipc.handle('open-desktop-settings', () => {
Expand Down

0 comments on commit a4d32dc

Please sign in to comment.