Skip to content

Commit

Permalink
Updated extension notification on update.
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Aug 13, 2018
1 parent 1438ced commit fe63d21
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 485 deletions.
36 changes: 25 additions & 11 deletions chrome-ext-files/js/background.js
Expand Up @@ -14,6 +14,20 @@
chrome.tabs.update(tabId, updateProperties, function (tab) { });
}

function openChangeLog() {
chrome.storage.sync.get({
showChangeLog: true
}, function (items) {
if (items.showChangeLog) {
chrome.tabs.create({
url: "https://altair.sirmuel.design/updated"
}, function (tab) {
console.log("New tab launched with https://altair.sirmuel.design/updated");
});
}
});
}

// Open the extension tab when the extension icon is clicked
chrome.browserAction.onClicked.addListener(function (tab) {
if (!curTabId) {
Expand All @@ -36,20 +50,20 @@
}
});

// Open the update page after every new update
// Show the update notification after every new update
chrome.runtime.onInstalled.addListener(function (details) {
if (details.reason === 'update') {
chrome.storage.sync.get({
showChangeLog: true
}, function (items) {
if (items.showChangeLog) {
chrome.tabs.create({
url: "https://altair.sirmuel.design/updated"
}, function (tab) {
console.log("New tab launched with https://altair.sirmuel.design/updated");
});
}
chrome.notifications.create({
type: 'basic',
iconUrl: 'assets/img/logo.png',
title: 'Altair has been updated',
message: 'Click to view changelog.'
}, function(notifId) {
});
}
});

chrome.notifications.onClicked.addListener(function (notifId) {
openChangeLog();
});
})();
3 changes: 2 additions & 1 deletion chrome-ext-files/manifest.json
Expand Up @@ -16,7 +16,8 @@
"http://*/",
"https://*/",
"tabs",
"storage"
"storage",
"notifications"
],
"content_security_policy": "script-src 'self'; object-src 'self'",
"background": {
Expand Down

0 comments on commit fe63d21

Please sign in to comment.