Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable nwc subscriptions #1149

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
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 { 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 @@
}
}

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 @@
<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 @@
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
Loading