Compare commits

...

2 Commits

Author SHA1 Message Date
ekzyis
21d61b9c8a
Update PR template (#1114)
Co-authored-by: ekzyis <ekzyis@ekzy.is>
2024-04-28 11:04:16 -05:00
ekzyis
0f95eb6c36
Only provide WebLN if enabled (#1115)
Co-authored-by: ekzyis <ekzyis@ekzy.is>
2024-04-28 11:03:07 -05:00
2 changed files with 16 additions and 6 deletions

View File

@ -24,14 +24,22 @@ You can mention here anything that you think is relevant for this PR. Some examp
## Checklist ## Checklist
- [ ] Are your changes backwards compatible? Are your changes backwards compatible? Please answer below:
<!-- put your answer about backwards compatibility here -->
<!-- <!--
If your PR is not ready for review yet, please mark your PR as a draft. If your PR is not ready for review yet, please mark your PR as a draft.
If changes were requested, request a new review when you incorporated the feedback. If changes were requested, request a new review when you incorporated the feedback.
--> -->
- [ ] Did you QA this? Could we deploy this straight to production? Did you QA this? Could we deploy this straight to production? Please answer below:
- [ ] For frontend changes: Tested on mobile? <!-- put your answer about QA here -->
- [ ] Did you introduce any new environment variables? If so, call them out explicitly in the PR description. For frontend changes: Tested on mobile? Please answer below:
<!-- put your answer about mobile QA here -->
Did you introduce any new environment variables? If so, call them out explicitly here:
<!-- put your answer about env vars here -->

View File

@ -7,9 +7,11 @@ import { LNCProvider, useLNC } from './lnc'
const WebLNContext = createContext({}) const WebLNContext = createContext({})
const isEnabled = p => [Status.Enabled, Status.Locked].includes(p?.status)
const syncProvider = (array, provider) => { const syncProvider = (array, provider) => {
const idx = array.findIndex(({ name }) => provider.name === name) const idx = array.findIndex(({ name }) => provider.name === name)
const enabled = [Status.Enabled, Status.Locked].includes(provider.status) const enabled = isEnabled(provider)
if (idx === -1) { if (idx === -1) {
// add provider to end if enabled // add provider to end if enabled
return enabled ? [...array, provider] : array return enabled ? [...array, provider] : array
@ -113,7 +115,7 @@ function RawWebLNProvider ({ children }) {
}, [setEnabledProviders]) }, [setEnabledProviders])
return ( return (
<WebLNContext.Provider value={{ provider: provider ? { sendPayment: sendPaymentWithToast } : null, enabledProviders, setProvider }}> <WebLNContext.Provider value={{ provider: isEnabled(provider) ? { sendPayment: sendPaymentWithToast } : null, enabledProviders, setProvider }}>
{children} {children}
</WebLNContext.Provider> </WebLNContext.Provider>
) )