diff options
author | Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com> | 2021-05-12 01:26:51 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-11 21:56:51 +0200 |
commit | 80d7ef19dbb4271416bd8b5bbf938e180c57e5f3 (patch) | |
tree | ec99db3b3b0727d7ac81c1ead70e17db0c1bb6b3 /src/lib | |
parent | Fixing issue with icons being garbled due to misconfiguration of gulp (diff) | |
download | ferdium-app-80d7ef19dbb4271416bd8b5bbf938e180c57e5f3.tar.gz ferdium-app-80d7ef19dbb4271416bd8b5bbf938e180c57e5f3.tar.zst ferdium-app-80d7ef19dbb4271416bd8b5bbf938e180c57e5f3.zip |
Method reuse (#1379)
* Used already exported common functions to avoid the same logic being repeated.
* Use a different package to retrieve the os-name for the 'About Dialog'.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/DBus.js | 8 | ||||
-rw-r--r-- | src/lib/Menu.js | 5 | ||||
-rw-r--r-- | src/lib/Tray.js | 16 |
3 files changed, 12 insertions, 17 deletions
diff --git a/src/lib/DBus.js b/src/lib/DBus.js index 957912efa..9baaea014 100644 --- a/src/lib/DBus.js +++ b/src/lib/DBus.js | |||
@@ -1,9 +1,5 @@ | |||
1 | import { | 1 | import { sessionBus } from 'dbus-next'; |
2 | sessionBus, | 2 | import { isLinux } from '../environment'; |
3 | } from 'dbus-next'; | ||
4 | import { | ||
5 | isLinux, | ||
6 | } from '../environment'; | ||
7 | 3 | ||
8 | export default class DBus { | 4 | export default class DBus { |
9 | bus = null; | 5 | bus = null; |
diff --git a/src/lib/Menu.js b/src/lib/Menu.js index d85f5706c..7bd273f6f 100644 --- a/src/lib/Menu.js +++ b/src/lib/Menu.js | |||
@@ -10,6 +10,9 @@ import { CUSTOM_WEBSITE_ID } from '../features/webControls/constants'; | |||
10 | import { workspaceActions } from '../features/workspaces/actions'; | 10 | import { workspaceActions } from '../features/workspaces/actions'; |
11 | import { workspaceStore } from '../features/workspaces/index'; | 11 | import { workspaceStore } from '../features/workspaces/index'; |
12 | import * as buildInfo from '../buildInfo.json'; // eslint-disable-line import/no-unresolved | 12 | import * as buildInfo from '../buildInfo.json'; // eslint-disable-line import/no-unresolved |
13 | import { ferdiVersion } from '../helpers/userAgent-helpers'; | ||
14 | |||
15 | const osName = require('os-name'); | ||
13 | 16 | ||
14 | const { | 17 | const { |
15 | app, Menu, dialog, systemPreferences, | 18 | app, Menu, dialog, systemPreferences, |
@@ -1025,7 +1028,7 @@ export default class FranzMenu { | |||
1025 | type: 'info', | 1028 | type: 'info', |
1026 | title: 'Franz Ferdinand', | 1029 | title: 'Franz Ferdinand', |
1027 | message: 'Ferdi', | 1030 | message: 'Ferdi', |
1028 | detail: `Version: ${remote.app.getVersion()}\nElectron: ${process.versions.electron}\nNode.js: ${process.version}\nPlatform: ${process.platform}\nArch: ${process.arch}\nBuild date: ${new Date(Number(buildInfo.timestamp))}\nGit SHA: ${buildInfo.gitHashShort}\nGit branch: ${buildInfo.gitBranch}`, | 1031 | detail: `Version: ${ferdiVersion}\nElectron: ${process.versions.electron}\nNode.js: ${process.version}\nPlatform: ${osName()}\nArch: ${process.arch}\nBuild date: ${new Date(Number(buildInfo.timestamp))}\nGit SHA: ${buildInfo.gitHashShort}\nGit branch: ${buildInfo.gitBranch}`, |
1029 | }); | 1032 | }); |
1030 | }, | 1033 | }, |
1031 | }; | 1034 | }; |
diff --git a/src/lib/Tray.js b/src/lib/Tray.js index 36f0de66d..f37b4eb7b 100644 --- a/src/lib/Tray.js +++ b/src/lib/Tray.js | |||
@@ -3,13 +3,9 @@ import { | |||
3 | } from 'electron'; | 3 | } from 'electron'; |
4 | import path from 'path'; | 4 | import path from 'path'; |
5 | import macosVersion from 'macos-version'; | 5 | import macosVersion from 'macos-version'; |
6 | import { | 6 | import { isMac, isWindows, isLinux } from '../environment'; |
7 | isMac, | ||
8 | isWindows, | ||
9 | isLinux, | ||
10 | } from '../environment'; | ||
11 | 7 | ||
12 | const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; | 8 | const FILE_EXTENSION = isWindows ? 'ico' : 'png'; |
13 | const INDICATOR_TRAY_PLAIN = 'tray'; | 9 | const INDICATOR_TRAY_PLAIN = 'tray'; |
14 | const INDICATOR_TRAY_UNREAD = 'tray-unread'; | 10 | const INDICATOR_TRAY_UNREAD = 'tray-unread'; |
15 | const INDICATOR_TRAY_INDIRECT = 'tray-indirect'; | 11 | const INDICATOR_TRAY_INDIRECT = 'tray-indirect'; |
@@ -110,7 +106,7 @@ export default class TrayIcon { | |||
110 | }); | 106 | }); |
111 | } | 107 | } |
112 | 108 | ||
113 | if (process.platform === 'darwin') { | 109 | if (isMac) { |
114 | this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { | 110 | this.themeChangeSubscriberId = systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', () => { |
115 | this._refreshIcon(); | 111 | this._refreshIcon(); |
116 | }); | 112 | }); |
@@ -128,7 +124,7 @@ export default class TrayIcon { | |||
128 | this.trayIcon.destroy(); | 124 | this.trayIcon.destroy(); |
129 | this.trayIcon = null; | 125 | this.trayIcon = null; |
130 | 126 | ||
131 | if (process.platform === 'darwin' && this.themeChangeSubscriberId) { | 127 | if (isMac && this.themeChangeSubscriberId) { |
132 | systemPreferences.unsubscribeNotification(this.themeChangeSubscriberId); | 128 | systemPreferences.unsubscribeNotification(this.themeChangeSubscriberId); |
133 | this.themeChangeSubscriberId = null; | 129 | this.themeChangeSubscriberId = null; |
134 | } | 130 | } |
@@ -164,7 +160,7 @@ export default class TrayIcon { | |||
164 | 160 | ||
165 | this.trayIcon.setImage(this._getAsset('tray', this._getAssetFromIndicator(this.indicator))); | 161 | this.trayIcon.setImage(this._getAsset('tray', this._getAssetFromIndicator(this.indicator))); |
166 | 162 | ||
167 | if (process.platform === 'darwin') { | 163 | if (isMac) { |
168 | this.trayIcon.setPressedImage( | 164 | this.trayIcon.setPressedImage( |
169 | this._getAsset('tray', `${this._getAssetFromIndicator(this.indicator)}-active`), | 165 | this._getAsset('tray', `${this._getAssetFromIndicator(this.indicator)}-active`), |
170 | ); | 166 | ); |
@@ -174,7 +170,7 @@ export default class TrayIcon { | |||
174 | _getAsset(type, asset) { | 170 | _getAsset(type, asset) { |
175 | let { platform } = process; | 171 | let { platform } = process; |
176 | 172 | ||
177 | if (platform === 'darwin' && (nativeTheme.shouldUseDarkColors || macosVersion.isGreaterThanOrEqualTo('11'))) { | 173 | if (isMac && (nativeTheme.shouldUseDarkColors || macosVersion.isGreaterThanOrEqualTo('11'))) { |
178 | platform = `${platform}-dark`; | 174 | platform = `${platform}-dark`; |
179 | } | 175 | } |
180 | 176 | ||