diff --git a/_locales/en/messages.json b/_locales/en/messages.json index fb24ff4..1041f66 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -117,5 +117,7 @@ "notificationNoUpdateTitle": { "message": "No updates available" }, "notificationNoUpdateDetail": { "message": "There aren't any updates for Caret at this time." }, "notificationUpdateOK": { "message": "Yes, update and restart" }, - "notificationUpdateWait": { "message": "No thanks" } + "notificationUpdateWait": { "message": "No thanks" }, + "notificationUpdated": { "message": "Caret has been updated" }, + "notificationUpdatedDetail": { "message": "Now at version $1. Click to see the changelog in the Chrome store." } } diff --git a/installer.js b/installer.js index 5eae9ed..3a13b47 100644 --- a/installer.js +++ b/installer.js @@ -1,21 +1,39 @@ +var notification = "upgraded"; + chrome.runtime.onInstalled.addListener(function(e) { //this is where we'll track upgrades if (!e.previousVersion) return; + var manifest = chrome.runtime.getManifest(); + var semver = e.previousVersion.split("."); var major = semver[0]; var minor = semver[1]; var build = semver[2]; - console.log("Upgrading Caret from version " + e.previousVersion); + if (e.previousVersion != manifest.version) { + //let the user know + chrome.notifications.create(notification, { + type: "basic", + iconUrl: "icon-128.png", + title: chrome.i18n.getMessage("notificationUpdated"), + message: chrome.i18n.getMessage("notificationUpdatedDetail", [manifest.version]), + isClickable: true + }, function(id) { notification = id }); + } + + // console.log("Upgrading Caret from version " + e.previousVersion); /* - As with Android database upgrades, we'll perform these as a series of if statements, ordered by increasing - version number. We should also provide a notification that the system is upgrading, and prevent opening new - windows until the process finishes. In theory, this script shares a document with background.js, so they can - just use a common flag to halt the openWindow process during upgrades. + As with Android database upgrades, we'll perform these as a series of if statements, ordered by increasing version number. We should also provide a notification that the system is upgrading, and prevent opening new windows until the process finishes. In theory, this script shares a document with background.js, so they can just use a common flag to halt the openWindow process during upgrades. */ +}); + + +chrome.notifications.onClicked.addListener(function(id) { + if (id != notification) return; + window.open("https://chrome.google.com/webstore/detail/caret/fljalecfjciodhpcledpamjachpmelml", "target=_blank"); }); \ No newline at end of file