Skip to content

Commit

Permalink
Open PR when clicking on notification
Browse files Browse the repository at this point in the history
  • Loading branch information
rkclark committed Mar 10, 2019
1 parent 5734a62 commit cdbbd74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 2 additions & 0 deletions scripts/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

global.electron = {};
13 changes: 10 additions & 3 deletions src/apollo/processNotifications.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import reviewRequested from './notificationRules/reviewRequested';

const triggerNotification = ({ title, message }) => {
const { shell } = window.electron;

const triggerNotification = ({ notification: { title, message }, url }) => {
/* eslint-disable no-new */
new Notification(title, {
const notification = new Notification(title, {
body: message,
});
/* eslint-enable no-new */

notification.onclick = event => {
event.preventDefault(); // Prevent the OS from focusing on Pullp
shell.openExternal(url); // Open the PR url in the user's default browser
};
};

export default ({
Expand All @@ -17,7 +24,7 @@ export default ({
];

newNotifications.forEach(notification => {
triggerNotification(notification);
triggerNotification({ notification, url: pullRequest.url });
});

return [...existingNotifications, ...newNotifications];
Expand Down

0 comments on commit cdbbd74

Please sign in to comment.