From b5727ca80c9da424a47a44de06abf9ca1156f1cc Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Thu, 26 Sep 2019 01:32:52 +0900 Subject: [PATCH 1/2] refs #948 Through auto-launch in darwin --- src/main/index.ts | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index 7879d517..d19c05c5 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -142,10 +142,18 @@ const accountCache = new AccountCache(accountCachePath) const soundBasePath = process.env.NODE_ENV === 'development' ? path.join(__dirname, '../../build/sounds/') : path.join(process.resourcesPath!, 'build/sounds/') -const launcher = new AutoLaunch({ - name: 'Whalebird', - path: appPath -}) +let launcher: AutoLaunch | null = null + +// On MAS build, auto launch is not working. +// We have to use Launch Agent: https://github.com/Teamwork/node-auto-launch/issues/43 +// But it is too difficult to build, and Slack does not provide this function in MAS build. +// Therefore I don't provide this function for MacOS. +if (process.platform !== 'darwin') { + launcher = new AutoLaunch({ + name: 'Whalebird', + path: appPath + }) +} async function listAccounts(): Promise> { try { @@ -467,14 +475,18 @@ ipcMain.on('remove-all-accounts', (event: Event) => { }) ipcMain.on('change-auto-launch', (event: Event, enable: boolean) => { - launcher.isEnabled().then(enabled => { - if (!enabled && enable) { - launcher.enable() - } else if (enabled && !enable) { - launcher.disable() - } - event.sender.send('response-change-auto-launch', enable) - }) + if (launcher) { + launcher.isEnabled().then(enabled => { + if (!enabled && enable && launcher) { + launcher.enable() + } else if (enabled && !enable && launcher) { + launcher.disable() + } + event.sender.send('response-change-auto-launch', enable) + }) + } else { + event.sender.send('response-change-auto-launch', false) + } }) // badge @@ -882,7 +894,10 @@ ipcMain.on('toot-action-sound', () => { // preferences ipcMain.on('get-preferences', async (event: Event) => { const preferences = new Preferences(preferencesDBPath) - const enabled = await launcher.isEnabled() + let enabled = false + if (launcher) { + enabled = await launcher.isEnabled() + } await preferences .update({ general: { From 8ca4d4ba8dcc1e048d21d6adb4b50b9e90b7150c Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Thu, 26 Sep 2019 23:02:48 +0900 Subject: [PATCH 2/2] refs #948 Hide auto-login setting on darwin --- src/renderer/components/Preferences/General.vue | 9 +++++---- src/renderer/store/Preferences/General.ts | 11 +++++++++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/renderer/components/Preferences/General.vue b/src/renderer/components/Preferences/General.vue index 4918da89..48307c71 100644 --- a/src/renderer/components/Preferences/General.vue +++ b/src/renderer/components/Preferences/General.vue @@ -24,7 +24,7 @@ - +

{{ $t('preferences.general.other.title') }}

@@ -34,14 +34,15 @@