Deactivate tempProfile when currentProfile is not includable. Fix #141.

This commit is contained in:
FelisCatus 2015-05-28 15:01:15 +08:00
parent 8f71270f1d
commit 0316041745

View File

@ -23,6 +23,7 @@ class Options
_revertToProfileName: null _revertToProfileName: null
_watchingProfiles: {} _watchingProfiles: {}
_tempProfile: null _tempProfile: null
_tempProfileActive: false
fallbackProfileName: 'system' fallbackProfileName: 'system'
_isSystem: false _isSystem: false
debugStr: 'Options' debugStr: 'Options'
@ -519,7 +520,9 @@ class Options
@currentProfileChanged(options?.reason) @currentProfileChanged(options?.reason)
if options? and options.proxy == false if options? and options.proxy == false
return Promise.resolve() return Promise.resolve()
if @_tempProfile? @_tempProfileActive = false
if @_tempProfile? and OmegaPac.Profiles.isIncludable(profile)
@_tempProfileActive = true
if @_tempProfile.defaultProfileName != profile.name if @_tempProfile.defaultProfileName != profile.name
@_tempProfile.defaultProfileName = profile.name @_tempProfile.defaultProfileName = profile.name
@_tempProfile.color = profile.color @_tempProfile.color = profile.color
@ -614,7 +617,7 @@ class Options
### ###
isCurrentProfileStatic: -> isCurrentProfileStatic: ->
return true if not @_currentProfileName return true if not @_currentProfileName
return false if @_tempProfile return false if @_tempProfileActive
currentProfile = @currentProfile() currentProfile = @currentProfile()
return false if OmegaPac.Profiles.isInclusive(currentProfile) return false if OmegaPac.Profiles.isInclusive(currentProfile)
return true return true
@ -898,8 +901,11 @@ class Options
if not @_currentProfileName if not @_currentProfileName
return Promise.resolve({profile: @_externalProfile, results: []}) return Promise.resolve({profile: @_externalProfile, results: []})
results = [] results = []
profile = @_tempProfile profile =
profile ?= OmegaPac.Profiles.byName(@_currentProfileName, @_options) if @_tempProfileActive
@_tempProfile
else
OmegaPac.Profiles.byName(@_currentProfileName, @_options)
while profile while profile
lastProfile = profile lastProfile = profile
result = OmegaPac.Profiles.match(profile, request) result = OmegaPac.Profiles.match(profile, request)