diff options
| author | Stephen Blott | 2016-10-02 12:33:39 +0100 |
|---|---|---|
| committer | GitHub | 2016-10-02 12:33:39 +0100 |
| commit | a6af88d3c88b3795a207aae6b364713e855ee602 (patch) | |
| tree | a6e125fe71d449d0f778d094c09506aa8d133951 | |
| parent | c370855afd2f9f4123de3e9d2d8492c036a605b6 (diff) | |
| parent | 5accaae40ebb50d5eaac19899fe1942574daf103 (diff) | |
| download | vimium-a6af88d3c88b3795a207aae6b364713e855ee602.tar.bz2 | |
Merge pull request #2284 from smblott-github/silent-releases
Enable silent/patch releases.
| -rw-r--r-- | background_scripts/main.coffee | 50 | ||||
| -rw-r--r-- | tests/unit_tests/utils_test.coffee | 5 |
2 files changed, 34 insertions, 21 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index b99b975f..57b5bf67 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -18,7 +18,6 @@ chrome.runtime.onInstalled.addListener ({ reason }) -> for file in files func tab.id, { file: file, allFrames: contentScripts.all_frames }, checkLastRuntimeError -currentVersion = Utils.getCurrentVersion() frameIdsForTab = {} portsForTab = {} root.urlForTab = {} @@ -89,7 +88,7 @@ getHelpDialogHtml = ({showUnboundCommands, showCommandNames, customTitle}) -> commandsToKey[command] = (commandsToKey[command] || []).concat(key) replacementStrings = - version: currentVersion + version: Utils.getCurrentVersion() title: customTitle || "Help" tip: if showCommandNames then "Tip: click command names to yank them to the clipboard." else " " @@ -473,28 +472,37 @@ window.runTests = -> open(chrome.runtime.getURL('tests/dom_tests/dom_tests.html' # Show notification on upgrade. do showUpgradeMessage = -> + currentVersion = Utils.getCurrentVersion() # Avoid showing the upgrade notification when previousVersion is undefined, which is the case for new # installs. - Settings.set "previousVersion", currentVersion unless Settings.get "previousVersion" - if Utils.compareVersions(currentVersion, Settings.get "previousVersion" ) == 1 - notificationId = "VimiumUpgradeNotification" - notification = - type: "basic" - iconUrl: chrome.runtime.getURL "icons/vimium.png" - title: "Vimium Upgrade" - message: "Vimium has been upgraded to version #{currentVersion}. Click here for more information." - isClickable: true - if chrome.notifications?.create? - chrome.notifications.create notificationId, notification, -> - unless chrome.runtime.lastError - Settings.set "previousVersion", currentVersion - chrome.notifications.onClicked.addListener (id) -> - if id == notificationId - chrome.tabs.getSelected null, (tab) -> - TabOperations.openUrlInNewTab {tab, tabId: tab.id, url: "https://github.com/philc/vimium#release-notes"} + Settings.set "previousVersion", currentVersion unless Settings.has "previousVersion" + previousVersion = Settings.get "previousVersion" + if Utils.compareVersions(currentVersion, previousVersion ) == 1 + currentVersionNumbers = currentVersion.split "." + previousVersionNumbers = previousVersion.split "." + if currentVersionNumbers[...2].join(".") == previousVersionNumbers[...2].join(".") + # We do not show an upgrade message for patch/silent releases. Such releases have the same major and + # minor version numbers. We do, however, update the recorded previous version. + Settings.set "previousVersion", currentVersion else - # We need to wait for the user to accept the "notifications" permission. - chrome.permissions.onAdded.addListener showUpgradeMessage + notificationId = "VimiumUpgradeNotification" + notification = + type: "basic" + iconUrl: chrome.runtime.getURL "icons/vimium.png" + title: "Vimium Upgrade" + message: "Vimium has been upgraded to version #{currentVersion}. Click here for more information." + isClickable: true + if chrome.notifications?.create? + chrome.notifications.create notificationId, notification, -> + unless chrome.runtime.lastError + Settings.set "previousVersion", currentVersion + chrome.notifications.onClicked.addListener (id) -> + if id == notificationId + chrome.tabs.getSelected null, (tab) -> + TabOperations.openUrlInNewTab {tab, tabId: tab.id, url: "https://github.com/philc/vimium#release-notes"} + else + # We need to wait for the user to accept the "notifications" permission. + chrome.permissions.onAdded.addListener showUpgradeMessage # The install date is shown on the logging page. chrome.runtime.onInstalled.addListener ({reason}) -> diff --git a/tests/unit_tests/utils_test.coffee b/tests/unit_tests/utils_test.coffee index 62471949..04cf34b6 100644 --- a/tests/unit_tests/utils_test.coffee +++ b/tests/unit_tests/utils_test.coffee @@ -99,9 +99,14 @@ context "Function currying", context "compare versions", should "compare correctly", -> assert.equal 0, Utils.compareVersions("1.40.1", "1.40.1") + assert.equal 0, Utils.compareVersions("1.40", "1.40.0") + assert.equal 0, Utils.compareVersions("1.40.0", "1.40") assert.equal -1, Utils.compareVersions("1.40.1", "1.40.2") assert.equal -1, Utils.compareVersions("1.40.1", "1.41") + assert.equal -1, Utils.compareVersions("1.40", "1.40.1") assert.equal 1, Utils.compareVersions("1.41", "1.40") + assert.equal 1, Utils.compareVersions("1.41.0", "1.40") + assert.equal 1, Utils.compareVersions("1.41.1", "1.41") context "makeIdempotent", setup -> |
