diff --git a/_locales/en/messages.json b/_locales/en/messages.json index e899aaf4e..301a2d70a 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1383,7 +1383,7 @@ }, "spellCheckDescription": { "message": "Enable spell check of text entered in message composition box", - "description": "Description of the media permission description" + "description": "Description of the spell check setting" }, "spellCheckWillBeEnabled": { "message": "Spell check will be enabled the next time Signal starts.", @@ -1393,6 +1393,10 @@ "message": "Spell check will be disabled the next time Signal starts.", "description": "Shown when the user disables spellcheck to indicate that they must restart Signal." }, + "autoLaunchDescription": { + "message": "Open at computer login", + "description": "Description for the automatic launch setting" + }, "clearDataHeader": { "message": "Clear Data", "description": "Header in the settings dialog for the section dealing with data deletion" diff --git a/js/settings_start.js b/js/settings_start.js index 1941271a8..579261c0b 100644 --- a/js/settings_start.js +++ b/js/settings_start.js @@ -36,6 +36,7 @@ const getInitialData = async () => ({ countMutedConversations: await window.getCountMutedConversations(), spellCheck: await window.getSpellCheck(), + autoLaunch: await window.getAutoLaunch(), incomingCallNotification: await window.getIncomingCallNotification(), callRingtoneNotification: await window.getCallRingtoneNotification(), diff --git a/js/views/settings_view.js b/js/views/settings_view.js index e1442aad4..66a38ee75 100644 --- a/js/views/settings_view.js +++ b/js/views/settings_view.js @@ -152,6 +152,12 @@ window.setSpellCheck(val); }, }); + 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'), @@ -259,6 +265,7 @@ spellCheckDirtyText: appStartSpellCheck ? i18n('spellCheckWillBeDisabled') : i18n('spellCheckWillBeEnabled'), + autoLaunchDescription: i18n('autoLaunchDescription'), }; }, onClose() { diff --git a/main.js b/main.js index a616ef46c..36c5e9e4a 100644 --- a/main.js +++ b/main.js @@ -1554,6 +1554,9 @@ installSettingsSetter('badge-count-muted-conversations'); installSettingsGetter('spell-check'); installSettingsSetter('spell-check', true); +installSettingsGetter('auto-launch'); +installSettingsSetter('auto-launch'); + installSettingsGetter('always-relay-calls'); installSettingsSetter('always-relay-calls'); installSettingsGetter('call-ringtone-notification'); diff --git a/preload.js b/preload.js index 97be98183..52aaf6c85 100644 --- a/preload.js +++ b/preload.js @@ -68,6 +68,10 @@ try { window.getServerPublicParams = () => config.serverPublicParams; window.getSfuUrl = () => config.sfuUrl; window.isBehindProxy = () => Boolean(config.proxyUrl); + window.getAutoLaunch = () => app.getLoginItemSettings().openAtLogin; + window.setAutoLaunch = value => { + app.setLoginItemSettings({ openAtLogin: Boolean(value) }); + }; function setSystemTheme() { window.systemTheme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light'; @@ -251,6 +255,9 @@ try { installGetter('spell-check', 'getSpellCheck'); installSetter('spell-check', 'setSpellCheck'); + installGetter('auto-launch', 'getAutoLaunch'); + installSetter('auto-launch', 'setAutoLaunch'); + installGetter('always-relay-calls', 'getAlwaysRelayCalls'); installSetter('always-relay-calls', 'setAlwaysRelayCalls'); diff --git a/settings.html b/settings.html index fde6bcf2e..a5def47d4 100644 --- a/settings.html +++ b/settings.html @@ -118,6 +118,10 @@ {{ spellCheckDirtyText }}

+
+ + +

{{ calling }}

diff --git a/settings_preload.js b/settings_preload.js index 5a138750e..0708ce7ef 100644 --- a/settings_preload.js +++ b/settings_preload.js @@ -64,6 +64,9 @@ window.setHideMenuBar = makeSetter('hide-menu-bar'); window.getSpellCheck = makeGetter('spell-check'); window.setSpellCheck = makeSetter('spell-check'); +window.getAutoLaunch = makeGetter('auto-launch'); +window.setAutoLaunch = makeSetter('auto-launch'); + window.getAlwaysRelayCalls = makeGetter('always-relay-calls'); window.setAlwaysRelayCalls = makeSetter('always-relay-calls'); diff --git a/ts/background.ts b/ts/background.ts index e7a41662b..49e7fe665 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -431,6 +431,9 @@ export async function startApp(): Promise { setAlwaysRelayCalls: (value: boolean) => window.storage.put('always-relay-calls', value), + getAutoLaunch: () => window.getAutoLaunch(), + setAutoLaunch: (value: boolean) => window.setAutoLaunch(value), + // eslint-disable-next-line eqeqeq isPrimary: () => window.textsecure.storage.user.getDeviceId() == '1', getSyncRequest: () => diff --git a/ts/util/lint/exceptions.json b/ts/util/lint/exceptions.json index 907cb1914..505d45bf8 100644 --- a/ts/util/lint/exceptions.json +++ b/ts/util/lint/exceptions.json @@ -1225,6 +1225,14 @@ "updated": "2021-02-26T18:44:56.450Z", "reasonDetail": "Static selector, read-only access" }, + { + "rule": "jQuery-$(", + "path": "js/views/settings_view.js", + "line": " el: this.$('.auto-launch-setting'),", + "reasonCategory": "usageTrusted", + "updated": "2021-05-11T20:38:03.542Z", + "reasonDetail": "Protected from arbitrary input" + }, { "rule": "jQuery-append(", "path": "js/views/settings_view.js", @@ -14233,4 +14241,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 diff --git a/ts/window.d.ts b/ts/window.d.ts index 3a53388c1..305f4c535 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -133,6 +133,8 @@ declare global { dataURLToBlobSync: any; loadImage: any; isBehindProxy: () => boolean; + getAutoLaunch: () => boolean; + setAutoLaunch: (value: boolean) => void; PQueue: typeof PQueue; PQueueType: PQueue;