Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions public/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@
"resets_every": "Resets every",
"resubscribe_date": "Resubscribe on",
"disable_connection": "Disable",
"disabled": "This subscription is disabled. Currently you can't re-enable subscriptions, but we're working to fix that. Check back soon!",
"disable_connection_confirm": "Are you sure you want to disable your subscription? Currently subscriptions can't be re-enabled, we're working to fix that."
"enable_connection": "Enable",
"disable_connection_confirm": "Are you sure you want to disable your subscription?"
},
"emergency_kit": {
"title": "Emergency Kit",
Expand Down
20 changes: 17 additions & 3 deletions src/routes/settings/Connections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { NWCEditor } from "~/components/NWCEditor";
import { useI18n } from "~/i18n/context";
import { useMegaStore } from "~/state/megaStore";
import { createDeepSignal, openLinkProgrammatically } from "~/utils";
import { enable_nwc_profile } from "~/workers/walletWorker";

function Spending(props: { spent: number; remaining: number }) {
const i18n = useI18n();
Expand Down Expand Up @@ -95,6 +96,15 @@ function NwcDetails(props: {
}
}

async function enableProfile() {
try {
await sw.enable_nwc_profile(props.profile.index);
props.refetch();
} catch (e) {
console.error(e);
}
}

async function openInNostrClient() {
const uri = props.profile.nwc_uri;
await openLinkProgrammatically(uri, {
Expand Down Expand Up @@ -153,9 +163,13 @@ function NwcDetails(props: {
<Show
when={props.profile.enabled}
fallback={
<InfoBox accent="red">
{i18n.t("settings.connections.disabled")}
</InfoBox>
<Button
layout="small"
intent="green"
onClick={enableProfile}
>
{i18n.t("settings.connections.enable_connection")}
</Button>
}
>
<Button layout="small" intent="green" onClick={props.onEdit}>
Expand Down
9 changes: 9 additions & 0 deletions src/workers/walletWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,15 @@ export async function delete_nwc_profile(index: number): Promise<void> {
await wallet!.delete_nwc_profile(index);
}

/**
* Re-enables a disabled nwc profile
* @param {number} index
* @returns {Promise<void>}
*/
export async function enable_nwc_profile(index: number): Promise<void> {
await wallet!.enable_nwc_profile(index);
}

/**
* Get nostr wallet connect profiles
* @returns {(NwcProfile)[]}
Expand Down