From 17427ae13f5832f687edd1fe96eea8c8c946028e Mon Sep 17 00:00:00 2001 From: FelisCatus Date: Thu, 27 Nov 2014 19:56:58 +0800 Subject: [PATCH] Fix a few issues related to upgrading. --- omega-pac/src/utils.coffee | 3 +++ .../src/switchysharp.coffee | 5 +++-- .../src/upgrade.coffee | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/omega-pac/src/utils.coffee b/omega-pac/src/utils.coffee index d315d11..1266c71 100644 --- a/omega-pac/src/utils.coffee +++ b/omega-pac/src/utils.coffee @@ -3,6 +3,9 @@ Revision = time = if time then new Date(time) else new Date() return time.getTime().toString(16) compare: (a, b) -> + return 0 if not a and not b + return -1 if not a + return 1 if not b return 1 if a.length > b.length return -1 if a.length < b.length return 1 if a > b diff --git a/omega-target-chromium-extension/src/switchysharp.coffee b/omega-target-chromium-extension/src/switchysharp.coffee index 066597f..2b4bf64 100644 --- a/omega-target-chromium-extension/src/switchysharp.coffee +++ b/omega-target-chromium-extension/src/switchysharp.coffee @@ -27,14 +27,15 @@ module.exports = class SwitchySharp if @_monitorTimerId clearInterval @_monitorTimerId @_monitorTimerId = null - if @_getOptionsResolver - @port.postMessage({action: 'getOptions'}) switch msg?.action when 'state' # State changed. OmegaTarget.Log.log(msg) + if @_getOptionsResolver + @port.postMessage({action: 'getOptions'}) when 'options' @_getOptionsResolver?(msg.options) + @_getOptionsResolver = null _onDisconnect: (msg) -> @port = null diff --git a/omega-target-chromium-extension/src/upgrade.coffee b/omega-target-chromium-extension/src/upgrade.coffee index 2f3c35a..5d1acfa 100644 --- a/omega-target-chromium-extension/src/upgrade.coffee +++ b/omega-target-chromium-extension/src/upgrade.coffee @@ -48,6 +48,7 @@ module.exports = (oldOptions, i18n) -> 'purple': '#d497ee' '': '#99ccee' + seenFixedProfile = false for own _, oldProfile of oldProfiles profile = null switch oldProfile['proxyMode'] @@ -64,6 +65,7 @@ module.exports = (oldOptions, i18n) -> else profile.pacUrl = url when 'manual' + seenFixedProfile = true profile = OmegaPac.Profiles.create( profileType: 'FixedProfile' ) @@ -116,6 +118,21 @@ module.exports = (oldOptions, i18n) -> OmegaPac.Profiles.updateRevision(profile) options[OmegaPac.Profiles.nameAsKey(profile.name)] = profile + if not seenFixedProfile + exampleFixedProfileName = 'Example Profile' + options[OmegaPac.Profiles.nameAsKey(exampleFixedProfileName)] = + bypassList: [ + pattern: "" + conditionType: "BypassCondition" + ] + profileType: "FixedProfile" + name: exampleFixedProfileName + color: "#99ccee" + fallbackProxy: + port: 8080 + scheme: "http" + host: "proxy.example.com" + startupId = config['startupProfileId'] options['-startupProfileName'] = nameMap[startupId] || ''