diff --git a/js/views/settings_view.js b/js/views/settings_view.js index 66a38ee755..91ea99f7b6 100644 --- a/js/views/settings_view.js +++ b/js/views/settings_view.js @@ -152,12 +152,14 @@ window.setSpellCheck(val); }, }); - new CheckboxView({ - el: this.$('.auto-launch-setting'), - name: 'auto-launch-setting', - value: window.initialData.autoLaunch, - setFn: window.setAutoLaunch, - }); + if (Settings.isAutoLaunchSupported()) { + new CheckboxView({ + el: this.$('.auto-launch-setting'), + name: 'auto-launch-setting', + value: window.initialData.autoLaunch, + setFn: window.setAutoLaunch, + }); + } if (Settings.isHideMenuBarSupported()) { new CheckboxView({ el: this.$('.menu-bar-setting'), @@ -230,6 +232,7 @@ isAudioNotificationSupported: Settings.isAudioNotificationSupported(), isHideMenuBarSupported: Settings.isHideMenuBarSupported(), isDrawAttentionSupported: Settings.isDrawAttentionSupported(), + isAutoLaunchSupported: Settings.isAutoLaunchSupported(), hasSystemTheme: true, themeLight: i18n('themeLight'), themeDark: i18n('themeDark'), diff --git a/settings.html b/settings.html index a5def47d4a..c08619b4c6 100644 --- a/settings.html +++ b/settings.html @@ -118,10 +118,12 @@ {{ spellCheckDirtyText }}

+ {{ #isAutoLaunchSupported }}
+ {{ /isAutoLaunchSupported }}

{{ calling }}

diff --git a/ts/test-node/types/Settings_test.ts b/ts/test-node/types/Settings_test.ts index 0b477beae6..0cd414fc18 100644 --- a/ts/test-node/types/Settings_test.ts +++ b/ts/test-node/types/Settings_test.ts @@ -102,6 +102,24 @@ describe('Settings', () => { }); }); + describe('isAutoLaunchSupported', () => { + it('returns true on Windows', () => { + sandbox.stub(process, 'platform').value('win32'); + sandbox.stub(os, 'release').returns('8.0.0'); + assert.isTrue(Settings.isAutoLaunchSupported()); + }); + + it('returns true on macOS', () => { + sandbox.stub(process, 'platform').value('darwin'); + assert.isTrue(Settings.isAutoLaunchSupported()); + }); + + it('returns false on Linux', () => { + sandbox.stub(process, 'platform').value('linux'); + assert.isFalse(Settings.isAutoLaunchSupported()); + }); + }); + describe('isHideMenuBarSupported', () => { it('returns false on macOS', () => { sandbox.stub(process, 'platform').value('darwin'); diff --git a/ts/types/Settings.ts b/ts/types/Settings.ts index e890088b83..2adead55bd 100644 --- a/ts/types/Settings.ts +++ b/ts/types/Settings.ts @@ -29,6 +29,12 @@ export const isAudioNotificationSupported = (): boolean => export const isNotificationGroupingSupported = (): boolean => !OS.isWindows() || OS.isWindows(MIN_WINDOWS_VERSION); +// Login item settings are only supported on macOS and Windows, according to [Electron's +// docs][0]. +// [0]: https://www.electronjs.org/docs/api/app#appsetloginitemsettingssettings-macos-windows +export const isAutoLaunchSupported = (): boolean => + OS.isWindows() || OS.isMacOS(); + // the "hide menu bar" option is specific to Windows and Linux export const isHideMenuBarSupported = (): boolean => !OS.isMacOS(); diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index 181dd1bc96..0948329945 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -1228,7 +1228,7 @@ { "rule": "jQuery-$(", "path": "js/views/settings_view.js", - "line": " el: this.$('.auto-launch-setting'),", + "line": " el: this.$('.auto-launch-setting'),", "reasonCategory": "usageTrusted", "updated": "2021-05-11T20:38:03.542Z", "reasonDetail": "Protected from arbitrary input" @@ -14225,4 +14225,4 @@ "updated": "2021-03-18T21:41:28.361Z", "reasonDetail": "A generic hook. Typically not to be used with non-DOM values." } -] +] \ No newline at end of file