Skip to content

Commit

Permalink
fix: Custom GLOBAL group display error
Browse files Browse the repository at this point in the history
  • Loading branch information
MystiPanda committed Feb 11, 2024
1 parent 5b3dc44 commit 9125a85
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export const getProxies = async () => {
getProxiesInner(),
getProxyProviders(),
]);

// provider name map
const providerMap = Object.fromEntries(
Object.entries(providerRecord).flatMap(([provider, item]) =>
Expand All @@ -131,24 +130,27 @@ export const getProxies = async () => {

const { GLOBAL: global, DIRECT: direct, REJECT: reject } = proxyRecord;

let groups: IProxyGroupItem[] = [];
let groups = Object.values(proxyRecord)
.filter((each) => each.name !== "GLOBAL" && each.all)
.map((each) => ({
...each,
all: each.all!.map((item) => generateItem(item)),
}));

if (global?.all) {
groups = global.all
let globalGroups = global.all
.filter((name) => proxyRecord[name]?.all)
.map((name) => proxyRecord[name])
.map((each) => ({
...each,
all: each.all!.map((item) => generateItem(item)),
}));
} else {
groups = Object.values(proxyRecord)
.filter((each) => each.name !== "GLOBAL" && each.all)
.map((each) => ({
...each,
all: each.all!.map((item) => generateItem(item)),
}))
.sort((a, b) => b.name.localeCompare(a.name));
let globalNames = globalGroups.map((each) => each.name);
groups = groups
.filter((group) => {
return !globalNames.includes(group.name);
})
.concat(globalGroups);
}

const proxies = [direct, reject].concat(
Expand Down

0 comments on commit 9125a85

Please sign in to comment.