Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Prevent ipc not defined errors in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Sep 21, 2017
1 parent 073b056 commit 319ce0b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/utils/metronome.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ class Metronome {
*/
_initIntervalToggler() {
const { ipc } = window;
ipc.on('blur', () => { this.interval = SYNC_INACTIVE_INTERVAL; });
ipc.on('focus', () => { this.interval = SYNC_ACTIVE_INTERVAL; });
if (ipc) {
ipc.on('blur', () => { this.interval = SYNC_INACTIVE_INTERVAL; });
ipc.on('focus', () => { this.interval = SYNC_ACTIVE_INTERVAL; });
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/utils/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Notification {
* @memberof Notify
*/
init() {
if (PRODUCTION) {
const { ipc } = window;
const { ipc } = window;
if (ipc) {
ipc.on('blur', () => { this.isFocused = false; });
ipc.on('focus', () => { this.isFocused = true; });
}
Expand Down
22 changes: 12 additions & 10 deletions src/utils/proxyLogin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ export default {
init: () => {
const { ipc } = window;

ipc.on('proxyLogin', (action, authInfo) => {
store.dispatch(dialogDisplayed({
title: 'Proxy Authentication',
childComponent: ProxyDialog,
childComponentProps: {
authInfo,
callback: (username, password) => ipc.send('proxyCredentialsEntered', username, password),
},
}));
});
if (ipc) {
ipc.on('proxyLogin', (action, authInfo) => {
store.dispatch(dialogDisplayed({
title: 'Proxy Authentication',
childComponent: ProxyDialog,
childComponentProps: {
authInfo,
callback: (username, password) => ipc.send('proxyCredentialsEntered', username, password),
},
}));
});
}
},
};

0 comments on commit 319ce0b

Please sign in to comment.