Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* desktop notification - initial commit * notification open on app hidden * notification click action: nav to local node page regardless of tab selected when app is closed * launch notification on app blurred * quit app on quit selection on close main window * code review changes * code review changes and merged with develop * code review changes * code review changes
- Loading branch information
Showing
11 changed files
with
106 additions
and
15 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as notificationsService } from './notificationsService'; // eslint-disable-line import/prefer-default-export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import path from 'path'; | ||
import { ipcRenderer } from 'electron'; | ||
import { ipcConsts } from '/vars'; | ||
|
||
// @flow | ||
class NotificationsService { | ||
static notify = ({ title, notification, callback }: { title: string, notification: string, callback: () => void }) => { | ||
NotificationsService.getNotificationAllowedStatus().then(({ isNotificationAllowed }: { isNotificationAllowed: boolean }) => { | ||
if (isNotificationAllowed) { | ||
const notificationOptions: any = { | ||
body: notification, | ||
icon: path.join(__dirname, '..', 'app', 'assets', 'icons', 'app_icon.png') | ||
}; | ||
const desktopNotification = new Notification(title || 'Alert', notificationOptions); | ||
desktopNotification.onclick = () => { | ||
ipcRenderer.send(ipcConsts.NOTIFICATION_CLICK); | ||
callback && callback(); | ||
}; | ||
} | ||
}); | ||
}; | ||
|
||
static getNotificationAllowedStatus = async () => { | ||
const isPermitted = await Notification.requestPermission(); | ||
ipcRenderer.send(ipcConsts.CAN_NOTIFY); | ||
return new Promise((resolve) => { | ||
ipcRenderer.once(ipcConsts.CAN_NOTIFY_SUCCESS, (event, isInFocus) => { | ||
resolve({ isNotificationAllowed: isPermitted && !isInFocus }); | ||
}); | ||
}); | ||
}; | ||
} | ||
|
||
export default NotificationsService; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters