Skip to content

Commit

Permalink
Merge pull request #17 from Gauravbhatt19/fix/16
Browse files Browse the repository at this point in the history
(#16) Resetting Alarms everytime Chrome starts
  • Loading branch information
Gauravbhatt19 authored Feb 9, 2021
2 parents 0fe8bd9 + 44955ff commit 8cc5626
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ chrome.storage.sync.get(['checkedNotifications'], function(storedData) {
priority: 0
});
});

chrome.runtime.onStartup.addListener(function () {
setAlarms(storedCheckedNotifications);
});
});

function getObjectElement(haystack, key, value) {
Expand All @@ -28,3 +32,16 @@ function getObjectElement(haystack, key, value) {
}
return false;
}

function setAlarms(checkedNotifications){
chrome.alarms.clearAll();
checkedNotifications.forEach(function(notification){
chrome.alarms.create(
notification.id,
{
when: Date.now() + notification.cycleTime * 60000,
periodInMinutes: notification.cycleTime
}
);
});
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Mind me please",
"version": "1.0",
"version": "1.0.2",
"description": "Health reminders while working on the desk",
"icons": {
"128": "assets/png/icon128.png",
Expand Down
1 change: 1 addition & 0 deletions popup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function getCheckedNotifications(storedCheckedNotifications) {
'id': checkedNotification.id,
'title': checkedNotification.title,
'quote': checkedNotification.quote,
'cycleTime': checkedNotification.cycleTime
});
}
}
Expand Down

0 comments on commit 8cc5626

Please sign in to comment.