fixed automatic activation of profile after importing

This commit is contained in:
coolcoala
2025-07-14 05:07:57 +03:00
parent ce3b0bb479
commit b1e3283a24

View File

@@ -2,7 +2,7 @@ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } f
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useForm } from "react-hook-form"; import { useForm } from "react-hook-form";
import { createProfile, patchProfile, importProfile } from "@/services/cmds"; import { createProfile, patchProfile, importProfile, enhanceProfiles } from "@/services/cmds";
import { useProfiles } from "@/hooks/use-profiles"; import { useProfiles } from "@/hooks/use-profiles";
import { showNotice } from "@/services/noticeService"; import { showNotice } from "@/services/noticeService";
import { version } from "@root/package.json"; import { version } from "@root/package.json";
@@ -132,6 +132,7 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>((props, ref) =>
await importProfile(importUrl); await importProfile(importUrl);
showNotice("success", t("Profile Imported Successfully")); showNotice("success", t("Profile Imported Successfully"));
props.onChange(); props.onChange();
await enhanceProfiles();
setOpen(false); setOpen(false);
} catch (err) { } catch (err) {
showNotice("info", t("Import failed, retrying with Clash proxy...")); showNotice("info", t("Import failed, retrying with Clash proxy..."));
@@ -139,6 +140,7 @@ export const ProfileViewer = forwardRef<ProfileViewerRef, Props>((props, ref) =>
await importProfile(importUrl, { with_proxy: false, self_proxy: true }); await importProfile(importUrl, { with_proxy: false, self_proxy: true });
showNotice("success", t("Profile Imported with Clash proxy")); showNotice("success", t("Profile Imported with Clash proxy"));
props.onChange(); props.onChange();
await enhanceProfiles();
setOpen(false); setOpen(false);
} catch (retryErr: any) { } catch (retryErr: any) {
showNotice("error", `${t("Import failed even with Clash proxy")}: ${retryErr?.message || retryErr.toString()}`); showNotice("error", `${t("Import failed even with Clash proxy")}: ${retryErr?.message || retryErr.toString()}`);