Commit b85a74c 1 parent f648824 commit b85a74c Copy full SHA for b85a74c
File tree 2 files changed +7
-19
lines changed
2 files changed +7
-19
lines changed Original file line number Diff line number Diff line change @@ -5,17 +5,13 @@ import {
5
5
WebResponseDetails ,
6
6
} from "./adapters" ;
7
7
import { setIndicator } from "./services/indicator" ;
8
- import {
9
- getAuthInfos ,
10
- getCurrentProxySetting ,
11
- onCurrentProxySettingChanged ,
12
- } from "./services/proxy" ;
8
+ import { getAuthInfos , getCurrentProxySetting } from "./services/proxy" ;
13
9
14
10
// indicator
15
11
async function initIndicator ( ) {
16
12
await setIndicator ( await getCurrentProxySetting ( ) ) ;
17
- onCurrentProxySettingChanged ( async ( proxy ) => {
18
- await setIndicator ( proxy ) ;
13
+ Host . onProxyChanged ( async ( ) => {
14
+ await setIndicator ( await getCurrentProxySetting ( ) ) ;
19
15
} ) ;
20
16
}
21
17
Original file line number Diff line number Diff line change @@ -43,15 +43,6 @@ export async function getCurrentProxySetting() {
43
43
return await wrapProxySetting ( setting ) ;
44
44
}
45
45
46
- export function onCurrentProxySettingChanged (
47
- cb : ( setting : ProxySetting ) => void
48
- ) {
49
- Host . onProxyChanged ( async ( setting ) => {
50
- const ret = await wrapProxySetting ( setting ) ;
51
- cb ( ret ) ;
52
- } ) ;
53
- }
54
-
55
46
export async function setProxy ( val : ProxyProfile ) {
56
47
switch ( val . proxyType ) {
57
48
case "system" :
@@ -73,18 +64,19 @@ export async function setProxy(val: ProxyProfile) {
73
64
*/
74
65
export async function refreshProxy ( ) {
75
66
const current = await getCurrentProxySetting ( ) ;
76
-
77
67
// if it's not controlled by this extension, then do nothing
78
68
if ( ! current . activeProfile ) {
79
69
return ;
80
70
}
81
71
72
+ const newProfile = await getProfile ( current . activeProfile . profileID ) ;
73
+
82
74
// if it's preset profiles, then do nothing
83
- if ( current . activeProfile . proxyType in [ "system" , "direct" ] ) {
75
+ if ( ! newProfile || current . activeProfile . proxyType in [ "system" , "direct" ] ) {
84
76
return ;
85
77
}
86
78
87
- const profile = new ProfileConverter ( current . activeProfile , getProfile ) ;
79
+ const profile = new ProfileConverter ( newProfile , getProfile ) ;
88
80
await Host . setProxy ( await profile . toProxyConfig ( ) ) ;
89
81
}
90
82
You can’t perform that action at this time.
0 commit comments