fixed problem with profile inactivation after adding via deeplink on windows

This commit is contained in:
coolcoala
2025-07-21 02:46:41 +03:00
parent 50beb913de
commit a32c973ab8
3 changed files with 7 additions and 20 deletions

View File

@@ -565,7 +565,7 @@ pub async fn resolve_scheme(param: String) -> Result<()> {
Some(url) => { Some(url) => {
log::info!(target:"app", "decoded subscription url: {url}"); log::info!(target:"app", "decoded subscription url: {url}");
create_window(false); create_window(true);
match PrfItem::from_url(url.as_ref(), name, None, None).await { match PrfItem::from_url(url.as_ref(), name, None, None).await {
Ok(item) => { Ok(item) => {
let uid = item.uid.clone().unwrap(); let uid = item.uid.clone().unwrap();

View File

@@ -44,9 +44,9 @@ const handleNoticeMessage = (
switch (status) { switch (status) {
case "import_sub_url::ok": case "import_sub_url::ok":
mutate("getProfiles"); mutate("getProfiles");
navigate("/", { state: { activateProfile: msg } }); navigate("/");
showNotice("success", t("Import Subscription Successful")); showNotice("success", t("Import Subscription Successful"));
window.dispatchEvent(new CustomEvent('activate-profile', { detail: msg })); sessionStorage.setItem('activateProfile', msg);
break; break;
case "import_sub_url::error": case "import_sub_url::error":
showNotice("error", msg); showNotice("error", msg);

View File

@@ -78,26 +78,13 @@ const MinimalHomePage: React.FC = () => {
); );
useEffect(() => { useEffect(() => {
const handleActivationEvent = (event: Event) => { const uidToActivate = sessionStorage.getItem('activateProfile');
const customEvent = event as CustomEvent<string>;
const profileId = customEvent.detail;
if (profileId) {
setUidToActivate(profileId);
}
};
window.addEventListener('activate-profile', handleActivationEvent);
return () => {
window.removeEventListener('activate-profile', handleActivationEvent);
};
}, []);
useEffect(() => {
if (uidToActivate && profileItems.some(p => p.uid === uidToActivate)) { if (uidToActivate && profileItems.some(p => p.uid === uidToActivate)) {
activateProfile(uidToActivate, false); activateProfile(uidToActivate, false);
setUidToActivate(null); sessionStorage.removeItem('activateProfile');
} }
}, [uidToActivate, profileItems, activateProfile]); }, [profileItems, activateProfile]);
const handleProfileChange = useLockFn(async (uid: string) => { const handleProfileChange = useLockFn(async (uid: string) => {
if (profiles?.current === uid) return; if (profiles?.current === uid) return;