Skip to content

Commit

Permalink
Re-enable nwc subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed May 9, 2024
1 parent 1fff601 commit 0d64307
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
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";

Check warning on line 38 in src/routes/settings/Connections.tsx

View workflow job for this annotation

GitHub Actions / code_quality

'enable_nwc_profile' is defined but never used. Allowed unused vars must match /^_/u

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);

Check failure on line 932 in src/workers/walletWorker.ts

View workflow job for this annotation

GitHub Actions / Build APK

Property 'enable_nwc_profile' does not exist on type 'MutinyWallet'. Did you mean 'create_nwc_profile'?

Check failure on line 932 in src/workers/walletWorker.ts

View workflow job for this annotation

GitHub Actions / code_quality

Property 'enable_nwc_profile' does not exist on type 'MutinyWallet'. Did you mean 'create_nwc_profile'?

Check failure on line 932 in src/workers/walletWorker.ts

View workflow job for this annotation

GitHub Actions / Build iOS

Property 'enable_nwc_profile' does not exist on type 'MutinyWallet'. Did you mean 'create_nwc_profile'?
}

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

0 comments on commit 0d64307

Please sign in to comment.