mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2026-01-07 08:14:30 +01:00
use capacitor AppLauncher instead of Browser
This commit is contained in:
committed by
Tony Giorgio
parent
761222c85e
commit
2c4c37c23f
@@ -121,15 +121,9 @@ function NwcDetails(props: {
|
||||
}
|
||||
}
|
||||
|
||||
function openInNostrClient() {
|
||||
async function openInNostrClient() {
|
||||
const uri = props.profile.nwc_uri;
|
||||
openLinkProgrammatically(uri);
|
||||
}
|
||||
|
||||
function openInPrimal() {
|
||||
const uri = props.profile.nwc_uri;
|
||||
const connectString = uri.replace("nostr+walletconnect", "primal");
|
||||
openLinkProgrammatically(connectString);
|
||||
await openLinkProgrammatically(uri);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -183,13 +177,9 @@ function NwcDetails(props: {
|
||||
props.profile.tag !== "Subscription"
|
||||
}
|
||||
>
|
||||
<Button layout="small" onClick={openInNostrClient}>
|
||||
<Button layout="small" intent="blue" onClick={openInNostrClient}>
|
||||
{i18n.t("settings.connections.open_in_nostr_client")}
|
||||
</Button>
|
||||
|
||||
<Button layout="small" onClick={openInPrimal}>
|
||||
{i18n.t("settings.connections.open_in_primal")}
|
||||
</Button>
|
||||
</Show>
|
||||
|
||||
<Button layout="small" onClick={confirmDelete}>
|
||||
@@ -317,8 +307,8 @@ function Nwc() {
|
||||
}
|
||||
}
|
||||
|
||||
function openCallbackUri() {
|
||||
openLinkProgrammatically(callbackUri());
|
||||
async function openCallbackUri() {
|
||||
await openLinkProgrammatically(callbackUri());
|
||||
setSearchParams({ callbackUri: "" });
|
||||
setCallbackDialogOpen(false);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
import { Browser } from "@capacitor/browser";
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
import { AppLauncher } from '@capacitor/app-launcher';
|
||||
|
||||
// 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;
|
||||
export async function openLinkProgrammatically(url?: string) {
|
||||
if (!url) return;
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
Browser.open({ url: href || "", windowName: "_blank" });
|
||||
const { value } = await AppLauncher.canOpenUrl({ url });
|
||||
|
||||
if (!value) {
|
||||
// Try to open in browser just in case that works glhf
|
||||
window.open(url || "", "_blank");
|
||||
return;
|
||||
} else {
|
||||
await AppLauncher.openUrl({ url});
|
||||
}
|
||||
} else {
|
||||
window.open(href || "", "_blank");
|
||||
window.open(url || "", "_blank");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user