aboutsummaryrefslogtreecommitdiffstats
path: root/src/electron/ipc-api
diff options
context:
space:
mode:
authorLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-05-12 01:26:51 +0530
committerLibravatar GitHub <noreply@github.com>2021-05-11 21:56:51 +0200
commit80d7ef19dbb4271416bd8b5bbf938e180c57e5f3 (patch)
treeec99db3b3b0727d7ac81c1ead70e17db0c1bb6b3 /src/electron/ipc-api
parentFixing issue with icons being garbled due to misconfiguration of gulp (diff)
downloadferdium-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/electron/ipc-api')
-rw-r--r--src/electron/ipc-api/appIndicator.js14
-rw-r--r--src/electron/ipc-api/autoUpdate.js3
2 files changed, 9 insertions, 8 deletions
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 {