mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2026-02-19 13:14:20 +01:00
fix safari app links
This commit is contained in:
committed by
Tony Giorgio
parent
f2f6d42d3f
commit
897899115c
@@ -1,4 +1,3 @@
|
||||
import { Browser } from "@capacitor/browser";
|
||||
import { NwcProfile, type BudgetPeriod } from "@mutinywallet/mutiny-wasm";
|
||||
import {
|
||||
createEffect,
|
||||
@@ -34,7 +33,7 @@ import {
|
||||
import { BudgetForm, NWCBudgetEditor } from "~/components/NWCBudgetEditor";
|
||||
import { useI18n } from "~/i18n/context";
|
||||
import { useMegaStore } from "~/state/megaStore";
|
||||
import { createDeepSignal } from "~/utils";
|
||||
import { createDeepSignal, openLinkProgrammatically } from "~/utils";
|
||||
|
||||
function mapIntervalToBudgetPeriod(
|
||||
interval: "Day" | "Week" | "Month" | "Year"
|
||||
@@ -112,13 +111,13 @@ function NwcDetails(props: {
|
||||
|
||||
function openInNostrClient() {
|
||||
const uri = props.profile.nwc_uri;
|
||||
Browser.open({ url: uri });
|
||||
openLinkProgrammatically(uri);
|
||||
}
|
||||
|
||||
function openInPrimal() {
|
||||
const uri = props.profile.nwc_uri;
|
||||
const connectString = uri.replace("nostr+walletconnect", "primal");
|
||||
Browser.open({ url: connectString });
|
||||
openLinkProgrammatically(connectString);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -197,7 +196,7 @@ function Nwc() {
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const queryName = searchParams.name;
|
||||
const [callbackDialogOpen, setCallbackDialogOpen] = createSignal(false);
|
||||
const [callbackUri, setCallbackUri] = createSignal<string | null>(null);
|
||||
const [callbackUri, setCallbackUri] = createSignal<string>();
|
||||
|
||||
// Profile creation / editing
|
||||
const [dialogOpen, setDialogOpen] = createSignal(!!queryName);
|
||||
@@ -279,11 +278,9 @@ function Nwc() {
|
||||
}
|
||||
|
||||
function openCallbackUri() {
|
||||
if (callbackUri()) {
|
||||
Browser.open({ url: callbackUri() as string });
|
||||
setSearchParams({ callbackUri: "" });
|
||||
setCallbackDialogOpen(false);
|
||||
}
|
||||
openLinkProgrammatically(callbackUri());
|
||||
setSearchParams({ callbackUri: "" });
|
||||
setCallbackDialogOpen(false);
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -15,3 +15,4 @@ export * from "./typescript";
|
||||
export * from "./useCopy";
|
||||
export * from "./words";
|
||||
export * from "./fetchZaps";
|
||||
export * from "./openLinkProgrammatically";
|
||||
|
||||
13
src/utils/openLinkProgrammatically.ts
Normal file
13
src/utils/openLinkProgrammatically.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Browser } from "@capacitor/browser";
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
|
||||
// Safari is a jerk and is aggressive about blocking window.open calls if the logic is too complex
|
||||
// Capacitor should be doing this for us but \o/
|
||||
export function openLinkProgrammatically(href?: string) {
|
||||
if (!href) return;
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
Browser.open({ url: href || "", windowName: "_blank" });
|
||||
} else {
|
||||
window.open(href || "", "_blank");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user