diff options
| author | Yonghui Zhang <[email protected]> | 2019-08-29 01:01:02 +0800 |
|---|---|---|
| committer | Yonghui Zhang <[email protected]> | 2019-08-29 01:01:02 +0800 |
| commit | 5c30108b803b15840eebba58e52b79abdb7d2be8 (patch) | |
| tree | be3ae900b4edaf81e02bc123e4601626db5ec191 /src | |
| parent | 43cf46eaadc094478750ad2fd92ee1d80e6b766b (diff) | |
sort ProxyGroups according its index in GLOBAL group.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ducks/proxies.js | 19 |
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; } |
