Skip to content

Commit ede8030

Browse files
Brendan Mulhollandrenovate[bot]afonsojramos
authored
chore(refactor): Simplify window re-open (#651)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Afonso Jorge Ramos <[email protected]>
1 parent 08406c2 commit ede8030

File tree

4 files changed

+5
-16
lines changed

4 files changed

+5
-16
lines changed

src/utils/comms.test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
updateTrayIcon,
3-
reOpenWindow,
43
openExternalLink,
54
setAutoLaunch,
65
restoreSetting,
@@ -33,12 +32,6 @@ describe('utils/comms.ts', () => {
3332
expect(ipcRenderer.send).toHaveBeenCalledWith('update-icon');
3433
});
3534

36-
it('should reopen the window', () => {
37-
reOpenWindow();
38-
expect(ipcRenderer.send).toHaveBeenCalledTimes(1);
39-
expect(ipcRenderer.send).toHaveBeenCalledWith('reopen-window');
40-
});
41-
4235
it('should restore a setting', () => {
4336
restoreSetting('foo', 'bar');
4437
expect(ipcRenderer.send).toHaveBeenCalledTimes(1);

src/utils/comms.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ export function updateTrayIcon(notificationsLength = 0): void {
2020
}
2121
}
2222

23-
export function reOpenWindow(): void {
24-
ipcRenderer.send('reopen-window');
25-
}
26-
2723
export function restoreSetting(setting, value): void {
2824
ipcRenderer.send(setting, value);
2925
}

src/utils/notifications.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as _ from 'lodash';
2+
import { ipcRenderer } from 'electron';
23

34
import { generateGitHubWebUrl, getCommentId } from './helpers';
45
import {
@@ -128,15 +129,13 @@ describe('utils/notifications.ts', () => {
128129
});
129130

130131
it('should click on a native notification (with more than 1 notification)', () => {
131-
jest.spyOn(comms, 'reOpenWindow');
132-
133132
const nativeNotification = notificationsHelpers.raiseNativeNotification(
134133
mockedGithubNotifications,
135134
mockAccounts,
136135
);
137136
nativeNotification.onclick(null);
138137

139-
expect(comms.reOpenWindow).toHaveBeenCalledTimes(1);
138+
expect(ipcRenderer.send).toHaveBeenCalledWith('reopen-window');
140139
});
141140

142141
it('should play a sound', () => {

src/utils/notifications.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { ipcRenderer } from 'electron';
12
const remote = require('@electron/remote');
23

34
import { openInBrowser } from '../utils/helpers';
4-
import { reOpenWindow, updateTrayIcon } from './comms';
5+
import { updateTrayIcon } from './comms';
56
import { Notification } from '../typesGithub';
67

78
import { AccountNotifications, SettingsState, AuthState } from '../types';
@@ -86,7 +87,7 @@ export const raiseNativeNotification = (
8687
remote.getCurrentWindow().hide();
8788
openInBrowser(notifications[0], accounts);
8889
} else {
89-
reOpenWindow();
90+
ipcRenderer.send('reopen-window');
9091
}
9192
};
9293

0 commit comments

Comments
 (0)