summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaishan <[email protected]>2019-08-29 21:58:57 +0800
committerGitHub <[email protected]>2019-08-29 21:58:57 +0800
commiteb39dac7bb026c6b7e8af1a72aa0cb6a4840e0a4 (patch)
treebe3ae900b4edaf81e02bc123e4601626db5ec191 /src
parent43cf46eaadc094478750ad2fd92ee1d80e6b766b (diff)
parent5c30108b803b15840eebba58e52b79abdb7d2be8 (diff)
Merge pull request #184 from comzyh/comzyh
Sort ProxyGroups according its index in GLOBAL group.
Diffstat (limited to 'src')
-rw-r--r--src/ducks/proxies.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/ducks/proxies.js b/src/ducks/proxies.js
index 8baa134..6683ca4 100644
--- a/src/ducks/proxies.js
+++ b/src/ducks/proxies.js
@@ -16,10 +16,25 @@ const OptimisticSwitchProxy = 'proxies/OptimisticSwitchProxy';
const CompletedRequestDelayForProxy = 'proxies/CompletedRequestDelayForProxy';
function retrieveGroupNamesFrom(proxies) {
- const groupNames = [];
+ var groupNames = [];
+ var globalAll = [];
for (const prop in proxies) {
const p = proxies[prop];
- if (p.all && Array.isArray(p.all)) groupNames.push(prop);
+ if (p.all && Array.isArray(p.all)) {
+ groupNames.push(prop);
+ if (prop == 'GLOBAL') {
+ globalAll = p.all;
+ }
+ }
+ }
+ if (globalAll) {
+ // Put GLOBAL in the end
+ globalAll.push('GLOBAL');
+ // Sort groups according to its index in GLOBAL group
+ groupNames = groupNames
+ .map(name => [globalAll.indexOf(name), name])
+ .sort((a, b) => a[0] - b[0])
+ .map(group => group[1]);
}
return groupNames;
}