select remote profile after import

This commit is contained in:
Hiddify 2023-01-05 02:38:32 +00:00
parent d0b47204f4
commit 259ca5c5b9

View file

@ -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) {