mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 23:08:13 -05:00
Discard reply when applying profile in popup menu.
This would make profile switching appear to be much faster especially for compiled profiles. Fix #211.
This commit is contained in:
parent
8eaf7cae64
commit
a54e02b503
@ -285,6 +285,7 @@ chrome.runtime.onMessage.addListener (request, sender, respond) ->
|
|||||||
return
|
return
|
||||||
|
|
||||||
promise = Promise.resolve().then -> method.apply(target, request.args)
|
promise = Promise.resolve().then -> method.apply(target, request.args)
|
||||||
|
return if request.noReply
|
||||||
|
|
||||||
promise.then (result) ->
|
promise.then (result) ->
|
||||||
if request.method == 'updateProfile'
|
if request.method == 'updateProfile'
|
||||||
@ -297,4 +298,4 @@ chrome.runtime.onMessage.addListener (request, sender, respond) ->
|
|||||||
respond(error: encodeError(error))
|
respond(error: encodeError(error))
|
||||||
|
|
||||||
# Wait for my response!
|
# Wait for my response!
|
||||||
return true
|
return true unless request.noReply
|
||||||
|
@ -8,6 +8,12 @@ angular.module('omegaTarget', []).factory 'omegaTarget', ($q) ->
|
|||||||
err
|
err
|
||||||
else
|
else
|
||||||
obj
|
obj
|
||||||
|
callBackgroundNoReply = (method, args...) ->
|
||||||
|
chrome.runtime.sendMessage({
|
||||||
|
method: method
|
||||||
|
args: args
|
||||||
|
noReply: true
|
||||||
|
})
|
||||||
callBackground = (method, args...) ->
|
callBackground = (method, args...) ->
|
||||||
d = $q['defer']()
|
d = $q['defer']()
|
||||||
chrome.runtime.sendMessage({
|
chrome.runtime.sendMessage({
|
||||||
@ -92,6 +98,8 @@ angular.module('omegaTarget', []).factory 'omegaTarget', ($q) ->
|
|||||||
return d.promise
|
return d.promise
|
||||||
applyProfile: (name) ->
|
applyProfile: (name) ->
|
||||||
callBackground('applyProfile', name)
|
callBackground('applyProfile', name)
|
||||||
|
applyProfileNoReply: (name) ->
|
||||||
|
callBackgroundNoReply('applyProfile', name)
|
||||||
addTempRule: (domain, profileName) ->
|
addTempRule: (domain, profileName) ->
|
||||||
callBackground('addTempRule', domain, profileName)
|
callBackground('addTempRule', domain, profileName)
|
||||||
addCondition: (condition, profileName) ->
|
addCondition: (condition, profileName) ->
|
||||||
|
@ -125,15 +125,22 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
|
|||||||
$scope.openOptions("#/profile/#{pname}?help=condition")
|
$scope.openOptions("#/profile/#{pname}?help=condition")
|
||||||
|
|
||||||
$scope.applyProfile = (profile) ->
|
$scope.applyProfile = (profile) ->
|
||||||
omegaTarget.applyProfile(profile.name).then(->
|
next = ->
|
||||||
if refreshOnProfileChange
|
|
||||||
return omegaTarget.refreshActivePage()
|
|
||||||
).then(->
|
|
||||||
if profile.profileType == 'SwitchProfile'
|
if profile.profileType == 'SwitchProfile'
|
||||||
return omegaTarget.state('web.switchGuide').then (switchGuide) ->
|
return omegaTarget.state('web.switchGuide').then (switchGuide) ->
|
||||||
if switchGuide == 'showOnFirstUse'
|
if switchGuide == 'showOnFirstUse'
|
||||||
return $scope.openOptions("#/profile/#{profile.name}")
|
return $scope.openOptions("#/profile/#{profile.name}")
|
||||||
).then ->
|
if not refreshOnProfileChange
|
||||||
|
omegaTarget.applyProfileNoReply(profile.name)
|
||||||
|
apply = next()
|
||||||
|
else
|
||||||
|
apply = omegaTarget.applyProfile(profile.name).then(->
|
||||||
|
return omegaTarget.refreshActivePage()
|
||||||
|
).then(next)
|
||||||
|
|
||||||
|
if apply
|
||||||
|
apply.then -> $window.close()
|
||||||
|
else
|
||||||
$window.close()
|
$window.close()
|
||||||
|
|
||||||
$scope.tempRuleMenu = {open: false}
|
$scope.tempRuleMenu = {open: false}
|
||||||
|
Loading…
Reference in New Issue
Block a user