aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/settings/settings/EditSettingsForm.js8
-rw-r--r--src/electron/ipc-api/appIndicator.js14
-rw-r--r--src/electron/ipc-api/autoUpdate.js3
-rw-r--r--src/helpers/userAgent-helpers.js2
-rw-r--r--src/index.js7
-rw-r--r--src/lib/DBus.js8
-rw-r--r--src/lib/Menu.js5
-rw-r--r--src/lib/Tray.js16
-rw-r--r--src/webview/contextMenuBuilder.js4
9 files changed, 33 insertions, 34 deletions
diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js
index c1a99e5fc..092411ec2 100644
--- a/src/components/settings/settings/EditSettingsForm.js
+++ b/src/components/settings/settings/EditSettingsForm.js
@@ -13,7 +13,7 @@ import PremiumFeatureContainer from '../../ui/PremiumFeatureContainer';
13import Input from '../../ui/Input'; 13import Input from '../../ui/Input';
14 14
15import { FRANZ_TRANSLATION } from '../../../config'; 15import { FRANZ_TRANSLATION } from '../../../config';
16import { isMac } from '../../../environment'; 16import { isMac, isWindows } from '../../../environment';
17 17
18const { 18const {
19 systemPreferences, 19 systemPreferences,
@@ -304,14 +304,14 @@ export default @observer class EditSettingsForm extends Component {
304 <Toggle field={form.$('enableSystemTray')} /> 304 <Toggle field={form.$('enableSystemTray')} />
305 <Toggle field={form.$('reloadAfterResume')} /> 305 <Toggle field={form.$('reloadAfterResume')} />
306 <Toggle field={form.$('startMinimized')} /> 306 <Toggle field={form.$('startMinimized')} />
307 {process.platform === 'win32' && ( 307 {isWindows && (
308 <Toggle field={form.$('minimizeToSystemTray')} /> 308 <Toggle field={form.$('minimizeToSystemTray')} />
309 )} 309 )}
310 {process.platform === 'win32' && ( 310 {isWindows && (
311 <Toggle field={form.$('closeToSystemTray')} /> 311 <Toggle field={form.$('closeToSystemTray')} />
312 )} 312 )}
313 <Toggle field={form.$('privateNotifications')} /> 313 <Toggle field={form.$('privateNotifications')} />
314 {(process.platform === 'win32' || process.platform === 'darwin') && ( 314 {(isWindows || isMac) && (
315 <Toggle field={form.$('notifyTaskBarOnMessage')} />)} 315 <Toggle field={form.$('notifyTaskBarOnMessage')} />)}
316 <Select field={form.$('navigationBarBehaviour')} /> 316 <Select field={form.$('navigationBarBehaviour')} />
317 317
diff --git a/src/electron/ipc-api/appIndicator.js b/src/electron/ipc-api/appIndicator.js
index 70f14d95e..0691e5170 100644
--- a/src/electron/ipc-api/appIndicator.js
+++ b/src/electron/ipc-api/appIndicator.js
@@ -1,9 +1,10 @@
1import { app, ipcMain } from 'electron'; 1import { app, ipcMain } from 'electron';
2import path from 'path'; 2import path from 'path';
3import { autorun } from 'mobx'; 3import { autorun } from 'mobx';
4import { isMac, isWindows, isLinux } from '../../environment';
4 5
5const INDICATOR_TASKBAR = 'taskbar'; 6const INDICATOR_TASKBAR = 'taskbar';
6const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; 7const FILE_EXTENSION = isWindows ? 'ico' : 'png';
7 8
8let isTrayIconEnabled; 9let isTrayIconEnabled;
9 10
@@ -28,29 +29,28 @@ export default (params) => {
28 // Flash TaskBar for windows, bounce Dock on Mac 29 // Flash TaskBar for windows, bounce Dock on Mac
29 if (!app.mainWindow.isFocused()) { 30 if (!app.mainWindow.isFocused()) {
30 if (params.settings.app.get('notifyTaskBarOnMessage')) { 31 if (params.settings.app.get('notifyTaskBarOnMessage')) {
31 if (process.platform === 'win32') { 32 if (isWindows) {
32 app.mainWindow.flashFrame(true); 33 app.mainWindow.flashFrame(true);
33 app.mainWindow.once('focus', () => app.mainWindow.flashFrame(false)); 34 app.mainWindow.once('focus', () => app.mainWindow.flashFrame(false));
34 } else if (process.platform === 'darwin') { 35 } else if (isMac) {
35 app.dock.bounce('informational'); 36 app.dock.bounce('informational');
36 } 37 }
37 } 38 }
38 } 39 }
39 40
40 // Update badge 41 // Update badge
41 if (process.platform === 'darwin' 42 if (isMac
42 && typeof (args.indicator) === 'string') { 43 && typeof (args.indicator) === 'string') {
43 app.dock.setBadge(args.indicator); 44 app.dock.setBadge(args.indicator);
44 } 45 }
45 46
46 if ((process.platform === 'darwin' 47 if ((isMac || isLinux)
47 || process.platform === 'linux')
48 && typeof (args.indicator) === 'number' 48 && typeof (args.indicator) === 'number'
49 ) { 49 ) {
50 app.badgeCount = args.indicator; 50 app.badgeCount = args.indicator;
51 } 51 }
52 52
53 if (process.platform === 'win32') { 53 if (isWindows) {
54 if (typeof args.indicator === 'number' 54 if (typeof args.indicator === 'number'
55 && args.indicator !== 0) { 55 && args.indicator !== 0) {
56 params.mainWindow.setOverlayIcon( 56 params.mainWindow.setOverlayIcon(
diff --git a/src/electron/ipc-api/autoUpdate.js b/src/electron/ipc-api/autoUpdate.js
index a81bc918f..ec7fa9d8a 100644
--- a/src/electron/ipc-api/autoUpdate.js
+++ b/src/electron/ipc-api/autoUpdate.js
@@ -1,5 +1,6 @@
1import { app, ipcMain } from 'electron'; 1import { app, ipcMain } from 'electron';
2import { autoUpdater } from 'electron-updater'; 2import { autoUpdater } from 'electron-updater';
3import { isMac, isWindows } from '../../environment';
3 4
4const debug = require('debug')('Ferdi:ipcApi:autoUpdate'); 5const debug = require('debug')('Ferdi:ipcApi:autoUpdate');
5 6
@@ -9,7 +10,7 @@ export default (params) => {
9 if (!enableUpdate) { 10 if (!enableUpdate) {
10 autoUpdater.autoInstallOnAppQuit = false; 11 autoUpdater.autoInstallOnAppQuit = false;
11 autoUpdater.autoDownload = false; 12 autoUpdater.autoDownload = false;
12 } else if (process.platform === 'darwin' || process.platform === 'win32' || process.env.APPIMAGE) { 13 } else if (isMac || isWindows || process.env.APPIMAGE) {
13 ipcMain.on('autoUpdate', (event, args) => { 14 ipcMain.on('autoUpdate', (event, args) => {
14 if (enableUpdate) { 15 if (enableUpdate) {
15 try { 16 try {
diff --git a/src/helpers/userAgent-helpers.js b/src/helpers/userAgent-helpers.js
index be6162464..fd0d16e2d 100644
--- a/src/helpers/userAgent-helpers.js
+++ b/src/helpers/userAgent-helpers.js
@@ -5,7 +5,7 @@ import { isMac, isWindows } from '../environment';
5 5
6// This helper gets included from the backend and frontend but we only need to use "remote" 6// This helper gets included from the backend and frontend but we only need to use "remote"
7// if we are in the frontend 7// if we are in the frontend
8const ferdiVersion = remote && remote.app ? remote.app.getVersion() : app.getVersion(); 8export const ferdiVersion = remote && remote.app ? remote.app.getVersion() : app.getVersion();
9 9
10function macOS() { 10function macOS() {
11 const version = macosVersion(); 11 const version = macosVersion();
diff --git a/src/index.js b/src/index.js
index a93040895..0fac386df 100644
--- a/src/index.js
+++ b/src/index.js
@@ -51,8 +51,9 @@ import {
51} from './config'; 51} from './config';
52import { asarPath } from './helpers/asar-helpers'; 52import { asarPath } from './helpers/asar-helpers';
53import { isValidExternalURL } from './helpers/url-helpers'; 53import { isValidExternalURL } from './helpers/url-helpers';
54import userAgent from './helpers/userAgent-helpers'; 54import userAgent, { ferdiVersion } from './helpers/userAgent-helpers';
55 55
56const osName = require('os-name');
56const debug = require('debug')('Ferdi:App'); 57const debug = require('debug')('Ferdi:App');
57 58
58// From Electron 9 onwards, app.allowRendererProcessReuse = true by default. This causes the app to crash on Windows due to the 59// From Electron 9 onwards, app.allowRendererProcessReuse = true by default. This causes the app to crash on Windows due to the
@@ -162,7 +163,7 @@ if (!settings.get('enableGPUAcceleration')) {
162} 163}
163 164
164app.setAboutPanelOptions({ 165app.setAboutPanelOptions({
165 applicationVersion: `Version: ${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}`, 166 applicationVersion: `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}`,
166 version: '', 167 version: '',
167}); 168});
168 169
@@ -394,7 +395,7 @@ app.on('ready', () => {
394 app.setAsDefaultProtocolClient('ferdi-dev'); 395 app.setAsDefaultProtocolClient('ferdi-dev');
395 } 396 }
396 397
397 if (process.platform === 'win32') { 398 if (isWindows) {
398 app.setUserTasks([{ 399 app.setUserTasks([{
399 program: process.execPath, 400 program: process.execPath,
400 arguments: `${isDevMode ? `${__dirname} ` : ''}--reset-window`, 401 arguments: `${isDevMode ? `${__dirname} ` : ''}--reset-window`,
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 @@
1import { 1import { sessionBus } from 'dbus-next';
2 sessionBus, 2import { isLinux } from '../environment';
3} from 'dbus-next';
4import {
5 isLinux,
6} from '../environment';
7 3
8export default class DBus { 4export 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';
10import { workspaceActions } from '../features/workspaces/actions'; 10import { workspaceActions } from '../features/workspaces/actions';
11import { workspaceStore } from '../features/workspaces/index'; 11import { workspaceStore } from '../features/workspaces/index';
12import * as buildInfo from '../buildInfo.json'; // eslint-disable-line import/no-unresolved 12import * as buildInfo from '../buildInfo.json'; // eslint-disable-line import/no-unresolved
13import { ferdiVersion } from '../helpers/userAgent-helpers';
14
15const osName = require('os-name');
13 16
14const { 17const {
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';
4import path from 'path'; 4import path from 'path';
5import macosVersion from 'macos-version'; 5import macosVersion from 'macos-version';
6import { 6import { isMac, isWindows, isLinux } from '../environment';
7 isMac,
8 isWindows,
9 isLinux,
10} from '../environment';
11 7
12const FILE_EXTENSION = process.platform === 'win32' ? 'ico' : 'png'; 8const FILE_EXTENSION = isWindows ? 'ico' : 'png';
13const INDICATOR_TRAY_PLAIN = 'tray'; 9const INDICATOR_TRAY_PLAIN = 'tray';
14const INDICATOR_TRAY_UNREAD = 'tray-unread'; 10const INDICATOR_TRAY_UNREAD = 'tray-unread';
15const INDICATOR_TRAY_INDIRECT = 'tray-indirect'; 11const 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
diff --git a/src/webview/contextMenuBuilder.js b/src/webview/contextMenuBuilder.js
index 7980e5344..f7d552ddd 100644
--- a/src/webview/contextMenuBuilder.js
+++ b/src/webview/contextMenuBuilder.js
@@ -6,6 +6,8 @@
6 * 6 *
7 * Source: https://github.com/electron-userland/electron-spellchecker/blob/master/src/context-menu-builder.js 7 * Source: https://github.com/electron-userland/electron-spellchecker/blob/master/src/context-menu-builder.js
8 */ 8 */
9import { isMac } from '../environment';
10
9const { 11const {
10 clipboard, nativeImage, remote, shell, 12 clipboard, nativeImage, remote, shell,
11} = require('electron'); 13} = require('electron');
@@ -261,7 +263,7 @@ module.exports = class ContextMenuBuilder {
261 return menu; 263 return menu;
262 } 264 }
263 265
264 if (process.platform === 'darwin') { 266 if (isMac) {
265 const webContents = this.getWebContents(); 267 const webContents = this.getWebContents();
266 268
267 const lookUpDefinition = new MenuItem({ 269 const lookUpDefinition = new MenuItem({