We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1cd043a commit 369befeCopy full SHA for 369befe
main.js
@@ -66,8 +66,16 @@ menubarApp.on('ready', () => {
66
}
67
});
68
69
+ ipcMain.handle('get-platform', async () => {
70
+ return process.platform;
71
+ });
72
+ ipcMain.handle('get-app-version', async () => {
73
+ return app.getVersion();
74
75
+
76
ipcMain.on('reopen-window', () => menubarApp.showWindow());
77
ipcMain.on('hide-window', () => menubarApp.hideWindow());
78
79
ipcMain.on('app-quit', () => menubarApp.app.quit());
80
ipcMain.on('update-icon', (_, arg) => {
81
if (!menubarApp.tray.isDestroyed()) {
@@ -78,12 +86,8 @@ menubarApp.on('ready', () => {
86
87
88
- ipcMain.handle('get-platform', async () => {
82
- return process.platform;
83
- });
84
-
85
- ipcMain.handle('get-app-version', async () => {
- return app.getVersion();
89
+ ipcMain.on('set-login-item-settings', (event, settings) => {
90
+ app.setLoginItemSettings(settings);
91
92
93
menubarApp.window.webContents.on('devtools-opened', () => {
src/utils/comms.test.ts
@@ -7,10 +7,8 @@ import {
7
8
const { ipcRenderer, shell } = require('electron');
9
10
-const remote = require('@electron/remote');
11
12
describe('utils/comms.ts', () => {
13
- beforeEach(function () {
+ beforeEach(function() {
14
jest.spyOn(ipcRenderer, 'send');
15
16
@@ -45,24 +43,20 @@ describe('utils/comms.ts', () => {
45
43
46
44
47
it('should setAutoLaunch (true)', () => {
48
- jest.spyOn(remote.app, 'setLoginItemSettings');
49
50
setAutoLaunch(true);
51
- expect(remote.app.setLoginItemSettings).toHaveBeenCalledTimes(1);
52
- expect(remote.app.setLoginItemSettings).toHaveBeenCalledWith({
+ expect(ipcRenderer.send).toHaveBeenCalledWith('set-login-item-settings', {
53
openAtLogin: true,
54
openAsHidden: true,
55
56
57
58
it('should setAutoLaunch (false)', () => {
59
60
61
setAutoLaunch(false);
62
63
64
- openAtLogin: false,
65
openAsHidden: false,
+ openAtLogin: false,
src/utils/comms.ts
@@ -1,15 +1,11 @@
1
2
3
4
export function openExternalLink(url: string): void {
5
shell.openExternal(url);
6
export function setAutoLaunch(value: boolean): void {
- remote.app.setLoginItemSettings({
- openAtLogin: value,
- openAsHidden: value,
+ ipcRenderer.send('set-login-item-settings', { openAtLogin: value, openAsHidden: value });
export function updateTrayIcon(notificationsLength = 0): void {
0 commit comments