From 259ca5c5b945533b09c011ce2ab1ad98e37b20ef Mon Sep 17 00:00:00 2001 From: Hiddify <114227601+hiddify@users.noreply.github.com> Date: Thu, 5 Jan 2023 02:38:32 +0000 Subject: [PATCH] select remote profile after import --- src/pages/profiles.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/pages/profiles.tsx b/src/pages/profiles.tsx index 0ccbd89..ac22fad 100644 --- a/src/pages/profiles.tsx +++ b/src/pages/profiles.tsx @@ -78,7 +78,7 @@ const ProfilePage = () => { // init selected array const { selected = [] } = profile; const selectedMap = Object.fromEntries( - selected.map((each) => [each.name!, each.now!]) +h selected.map((each) => [each.name!, each.now!]) ); let hasChange = false; @@ -104,21 +104,22 @@ const ProfilePage = () => { const onImport = async () => { if (!url) return; - setUrl(""); + setDisabled(true); try { await importProfile(url); Notice.success("Successfully import profile."); - + setUrl(""); getProfiles().then((newProfiles) => { mutate("getProfiles", newProfiles); - - const remoteItem = newProfiles.items?.find((e) => e.type === "remote"); - if (!newProfiles.current && remoteItem) { - const current = remoteItem.uid; + if (newProfiles.items && newProfiles.items.length>0){ + const lastItem = newProfiles.items[newProfiles.items.length-1]; + const current = lastItem.uid; patchProfiles({ current }); mutateLogs(); + closeAllConnections(); + Notice.success("Refresh clash config", 1000); } }); } catch (err: any) {