From 7a962c5f92935cdfc6f55c3a41befee0fa71b0aa Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Tue, 3 Oct 2023 14:38:31 -0500 Subject: [PATCH] more fixes --- src/routes/settings/Gift.tsx | 8 +++----- src/utils/baseUrl.ts | 12 ++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 src/utils/baseUrl.ts diff --git a/src/routes/settings/Gift.tsx b/src/routes/settings/Gift.tsx index eb41b70..be19711 100644 --- a/src/routes/settings/Gift.tsx +++ b/src/routes/settings/Gift.tsx @@ -41,6 +41,7 @@ import { import { useI18n } from "~/i18n/context"; import { useMegaStore } from "~/state/megaStore"; import { eify } from "~/utils"; +import { baseUrlAccountingForNative } from "~/utils/baseUrl"; import { createDeepSignal } from "~/utils/deepSignal"; type CreateGiftForm = { @@ -57,10 +58,7 @@ export function SingleGift(props: { const network = state.mutiny_wallet?.get_network(); - const baseUrl = - network === "bitcoin" - ? "https://app.mutinywallet.com" - : "https://signet-app.mutinywallet.com"; + const baseUrl = baseUrlAccountingForNative(network); const sharableUrl = () => baseUrl.concat(props.profile.url_suffix || ""); const amount = () => props.profile.budget_amount?.toString() || "0"; @@ -204,7 +202,7 @@ export default function GiftPage() { return Number(getValue(giftForm, "amount")) < 50000; }; - const selfHosted = state.mutiny_wallet?.get_network() === "signet"; + const selfHosted = state.settings?.selfhosted === "true"; const canGift = state.mutiny_plus || selfHosted; return ( diff --git a/src/utils/baseUrl.ts b/src/utils/baseUrl.ts new file mode 100644 index 0000000..3f31bab --- /dev/null +++ b/src/utils/baseUrl.ts @@ -0,0 +1,12 @@ +import { Capacitor } from "@capacitor/core"; + +// On mobile the origin URL is localhost, so we hardcode the base URL +export function baseUrlAccountingForNative(network?: string) { + if (Capacitor.isNativePlatform()) { + return network === "bitcoin" + ? "https://app.mutinywallet.com" + : "https://signet-app.mutinywallet.com"; + } else { + return window.location.origin; + } +}