Skip to content
Snippets Groups Projects
Unverified Commit 8bad2c21 authored by GyDi's avatar GyDi
Browse files

fix: adjust code

parent 2bcf6fb3
No related branches found
No related tags found
No related merge requests found
...@@ -83,27 +83,20 @@ const ProfilePage = () => { ...@@ -83,27 +83,20 @@ const ProfilePage = () => {
let hasChange = false; let hasChange = false;
const newSelected: typeof selected = [];
const { global, groups } = proxiesData; const { global, groups } = proxiesData;
[global, ...groups].forEach((group) => {
const { type, name, now } = group; [global, ...groups].forEach(({ type, name, now }) => {
if (!now || (type !== "Selector" && type !== "Fallback")) return;
if (type !== "Selector" && type !== "Fallback") return; if (selectedMap[name] != null && selectedMap[name] !== now) {
if (!now || selectedMap[name] === now) return;
if (selectedMap[name] == null) {
selectedMap[name] = now!;
} else {
hasChange = true; hasChange = true;
updateProxy(name, selectedMap[name]); updateProxy(name, selectedMap[name]);
} }
newSelected.push({ name, now });
}); });
// update profile selected list // update profile selected list
profile.selected = Object.entries(selectedMap).map(([name, now]) => ({ patchProfile(current!, { selected: newSelected });
name,
now,
}));
patchProfile(current!, { selected: profile.selected });
// update proxies cache // update proxies cache
if (hasChange) mutate("getProxies", getProxies()); if (hasChange) mutate("getProxies", getProxies());
}, 100); }, 100);
...@@ -122,11 +115,9 @@ const ProfilePage = () => { ...@@ -122,11 +115,9 @@ const ProfilePage = () => {
mutate("getProfiles", newProfiles); mutate("getProfiles", newProfiles);
const remoteItem = newProfiles.items?.find((e) => e.type === "remote"); const remoteItem = newProfiles.items?.find((e) => e.type === "remote");
if (!newProfiles.current && remoteItem) { if (!newProfiles.current && remoteItem) {
const current = remoteItem.uid; const current = remoteItem.uid;
patchProfiles({ current }); patchProfiles({ current });
mutateProfiles();
mutateLogs(); mutateLogs();
} }
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment