Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Towards #18: Sending Alert Notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
viveknigam3003 committed Jul 13, 2020
1 parent 6bce421 commit 70ca6ed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function doNotify(message) {
Notification.requestPermission().then(() => {
new window.Notification('Rucio Notifier', {
'body': message,
'icon': 'electorn-logo=2.png'
});
});
}
3 changes: 3 additions & 0 deletions src/components/Notifications/Reducers/NotificationReducer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { doNotify } from "../NativeNotifications/AlertNotification";

const notification = JSON.parse(localStorage.getItem('notifications'))

function notificationReducer(state = notification, action) {
Expand All @@ -14,6 +16,7 @@ function notificationReducer(state = notification, action) {
read: false,
});
console.log(newNotification);
doNotify(action.primary)
localStorage.setItem('notifications', JSON.stringify(newNotification))
return newNotification;

Expand Down

0 comments on commit 70ca6ed

Please sign in to comment.