From 75d54e77372b3e90324c91bd7c6c1f7f3bb52d86 Mon Sep 17 00:00:00 2001
From: Jacob Kiesel
Date: Tue, 11 May 2021 15:59:21 -0500
Subject: [PATCH] Add launch-on login option
See [#5244][0].
[0]: https://github.com/signalapp/Signal-Desktop/pull/5244
---
_locales/en/messages.json | 6 +++++-
js/settings_start.js | 1 +
js/views/settings_view.js | 7 +++++++
main.js | 3 +++
preload.js | 7 +++++++
settings.html | 4 ++++
settings_preload.js | 3 +++
ts/background.ts | 3 +++
ts/util/lint/exceptions.json | 10 +++++++++-
ts/window.d.ts | 2 ++
10 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index e899aaf4e3..301a2d70a6 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 1941271a8a..579261c0b8 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 e1442aad41..66a38ee755 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 a616ef46c0..36c5e9e4a4 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 97be98183b..52aaf6c85d 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 fde6bcf2e9..a5def47d4a 100644
--- a/settings.html
+++ b/settings.html
@@ -118,6 +118,10 @@
{{ spellCheckDirtyText }}
+
+
+
+
{{ calling }}
diff --git a/settings_preload.js b/settings_preload.js
index 5a138750e2..0708ce7ef7 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 e7a41662bb..49e7fe665f 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 907cb1914b..505d45bf8b 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 3a53388c16..305f4c5353 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;