diff --git a/public/i18n/en.json b/public/i18n/en.json index 465bf161..b3fb8de7 100644 --- a/public/i18n/en.json +++ b/public/i18n/en.json @@ -594,7 +594,10 @@ "learn_more": "Learn more about nostr", "import_profile": "Import a nostr profile", "delete_account": "Delete account", - "delete_account_confirm": "Deleting your nostr profile cannot be undone and will disable some social features of the wallet." + "delete_account_confirm": "Deleting a nostr profile cannot be undone and will disable some social features of the wallet.", + "unlink_account": "Unlink nostr profile", + "unlink_account_confirm": "Unlinking your nostr profile will reset your wallet to its default nostr profile.", + "delete_account_confirm_scary": "THIS PROFILE WILL BE DELETED ACROSS ALL NOSTR APPS." } }, "swap": { diff --git a/src/logic/mutinyWalletSetup.ts b/src/logic/mutinyWalletSetup.ts index 93b45884..27bcc3e0 100644 --- a/src/logic/mutinyWalletSetup.ts +++ b/src/logic/mutinyWalletSetup.ts @@ -257,7 +257,6 @@ export async function setupMutinyWallet( let nsec; // get nsec from secure storage - // TODO: might have to check Capacitor.isNativePlatform but I think it's fine try { const value = await SecureStoragePlugin.get({ key: "nsec" }); nsec = value.value; diff --git a/src/routes/Profile.tsx b/src/routes/Profile.tsx index 7310ae38..73ea6b38 100644 --- a/src/routes/Profile.tsx +++ b/src/routes/Profile.tsx @@ -42,11 +42,15 @@ export function Profile() { const [copy, copied] = useCopy({ copiedTimeout: 1000 }); + const profileDeleted = createMemo(() => { + return profile().deleted === true || profile().deleted === "true"; + }); + return ( - +
setConfirmOpen(false)} > - {i18n.t("settings.nostr_keys.delete_account_confirm")} +

{i18n.t("settings.nostr_keys.delete_account_confirm")}

+

+ {i18n.t("settings.nostr_keys.delete_account_confirm_scary")} +

+ + + ); +} + +function UnlinkAccount() { + const i18n = useI18n(); + + async function confirmUnlink() { + setConfirmOpen(true); + } + + const [confirmOpen, setConfirmOpen] = createSignal(false); + const [confirmLoading, setConfirmLoading] = createSignal(false); + + async function unlinkNostrAccount() { + setConfirmLoading(true); + try { + await SecureStoragePlugin.clear(); + window.location.href = "/"; + } catch (e) { + console.error(e); + } + setConfirmLoading(false); + } + + return ( + <> + + setConfirmOpen(false)} + > + {i18n.t("settings.nostr_keys.unlink_account_confirm")} ); @@ -74,6 +119,19 @@ export function NostrKeys() { const nsec = () => state.mutiny_wallet?.export_nsec(); const profile = () => state.mutiny_wallet?.get_nostr_profile(); + // @ts-expect-error we're checking for an extension + const windowHasNostr = window.nostr && window.nostr.getPublicKey; + + const [nsecInSecureStorage] = createResource(async () => { + try { + const value = await SecureStoragePlugin.get({ key: "nsec" }); + if (value) return true; + } catch (e) { + console.log("No nsec stored"); + return false; + } + }); + return ( @@ -111,19 +169,30 @@ export function NostrKeys() { - - - {i18n.t("settings.nostr_keys.import_profile")} - - + + + + {i18n.t("settings.nostr_keys.import_profile")} + + + + + + + + + + {i18n.t("settings.nostr_keys.import_profile")}