only trigger notification on major v change
parent
05f06075b2
commit
4fc1d3ef53
|
@ -37,23 +37,29 @@ chrome.app.runtime.onLaunched.addListener(function() {
|
|||
|
||||
chrome.runtime.onInstalled.addListener(function(details) {
|
||||
if (details.reason == 'update') {
|
||||
chrome.storage.local.get('update_notify', function(result) {
|
||||
if (typeof result.update_notify === 'undefined' || result.update_notify) {
|
||||
var manifest = chrome.runtime.getManifest();
|
||||
var options = {
|
||||
priority: 0,
|
||||
type: 'basic',
|
||||
title: manifest.name,
|
||||
message: chrome.i18n.getMessage('notifications_app_just_updated_to_version', [manifest.version]),
|
||||
iconUrl: '/images/icon_128.png',
|
||||
buttons: [{'title': chrome.i18n.getMessage('notifications_click_here_to_start_app')}]
|
||||
};
|
||||
var previousVersionArr = details.previousVersion.split('.');
|
||||
var currentVersionArr = chrome.runtime.getManifest().version.split('.');
|
||||
|
||||
chrome.notifications.create('baseflight_update', options, function(notificationId) {
|
||||
// empty
|
||||
});
|
||||
}
|
||||
});
|
||||
// only fire up notification sequence when one of the major version numbers changed
|
||||
if (currentVersionArr[0] != previousVersionArr[0] || currentVersionArr[1] != previousVersionArr[1]) {
|
||||
chrome.storage.local.get('update_notify', function(result) {
|
||||
if (typeof result.update_notify === 'undefined' || result.update_notify) {
|
||||
var manifest = chrome.runtime.getManifest();
|
||||
var options = {
|
||||
priority: 0,
|
||||
type: 'basic',
|
||||
title: manifest.name,
|
||||
message: chrome.i18n.getMessage('notifications_app_just_updated_to_version', [manifest.version]),
|
||||
iconUrl: '/images/icon_128.png',
|
||||
buttons: [{'title': chrome.i18n.getMessage('notifications_click_here_to_start_app')}]
|
||||
};
|
||||
|
||||
chrome.notifications.create('baseflight_update', options, function(notificationId) {
|
||||
// empty
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue