fixed problem with profile inactivation after adding via deeplink on windows
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user