diff --git a/src/pages/secondary/WalletPage/LightningAddressInput.tsx b/src/pages/secondary/WalletPage/LightningAddressInput.tsx
index f3149400..6fb6022f 100644
--- a/src/pages/secondary/WalletPage/LightningAddressInput.tsx
+++ b/src/pages/secondary/WalletPage/LightningAddressInput.tsx
@@ -28,26 +28,21 @@ export default function LightningAddressInput() {
const handleSave = async () => {
setSaving(true)
- let lud06 = profile.lud06
- let lud16 = profile.lud16
+ const profileContent = profileEvent ? JSON.parse(profileEvent.content) : {}
if (lightningAddress.startsWith('lnurl')) {
- lud06 = lightningAddress
+ profileContent.lud06 = lightningAddress
} else if (isEmail(lightningAddress)) {
- lud16 = lightningAddress
- } else {
+ profileContent.lud16 = lightningAddress
+ } else if (lightningAddress) {
toast.error(t('Invalid Lightning Address. Please enter a valid Lightning Address or LNURL.'))
setSaving(false)
return
+ } else {
+ delete profileContent.lud16
}
- const oldProfileContent = profileEvent ? JSON.parse(profileEvent.content) : {}
- const newProfileContent = {
- ...oldProfileContent,
- lud06,
- lud16
- }
const profileDraftEvent = createProfileDraftEvent(
- JSON.stringify(newProfileContent),
+ JSON.stringify(profileContent),
profileEvent?.tags
)
const newProfileEvent = await publish(profileDraftEvent)
diff --git a/src/pages/secondary/WalletPage/index.tsx b/src/pages/secondary/WalletPage/index.tsx
index 3dcb6dcc..154e88e0 100644
--- a/src/pages/secondary/WalletPage/index.tsx
+++ b/src/pages/secondary/WalletPage/index.tsx
@@ -1,5 +1,20 @@
+import { useSecondaryPage } from '@/PageManager'
+import {
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
+ AlertDialogTrigger
+} from '@/components/ui/alert-dialog'
+import { Button } from '@/components/ui/button'
import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
-import { Button as BcButton } from '@getalby/bitcoin-connect-react'
+import { toRizful } from '@/lib/link'
+import { useZap } from '@/providers/ZapProvider'
+import { disconnect, launchModal } from '@getalby/bitcoin-connect-react'
import { forwardRef } from 'react'
import { useTranslation } from 'react-i18next'
import DefaultZapAmountInput from './DefaultZapAmountInput'
@@ -9,16 +24,60 @@ import QuickZapSwitch from './QuickZapSwitch'
const WalletPage = forwardRef(({ index }: { index?: number }, ref) => {
const { t } = useTranslation()
+ const { push } = useSecondaryPage()
+ const { isWalletConnected, walletInfo } = useZap()
return (
-
-
-
-
-
-
-
+ {isWalletConnected ? (
+
+
+ {walletInfo?.node.alias && (
+
+ {t('Connected to')} {walletInfo.node.alias}
+
+ )}
+
+
+
+
+
+
+ {t('Are you absolutely sure?')}
+
+ {t('You will not be able to send zaps to others.')}
+
+
+
+ {t('Cancel')}
+ disconnect()}>
+ {t('Disconnect')}
+
+
+
+
+
+
+
+
+
+
+ ) : (
+
+
+
+
+ )}
)
})
diff --git a/src/providers/ZapProvider.tsx b/src/providers/ZapProvider.tsx
index b7c4fe05..51fa5195 100644
--- a/src/providers/ZapProvider.tsx
+++ b/src/providers/ZapProvider.tsx
@@ -1,7 +1,13 @@
+import lightningService from '@/services/lightning.service'
import storage from '@/services/local-storage.service'
-import { createContext, useContext, useState } from 'react'
+import { onConnected, onDisconnected } from '@getalby/bitcoin-connect-react'
+import { GetInfoResponse, WebLNProvider } from '@webbtc/webln-types'
+import { createContext, useContext, useEffect, useState } from 'react'
type TZapContext = {
+ isWalletConnected: boolean
+ provider: WebLNProvider | null
+ walletInfo: GetInfoResponse | null
defaultZapSats: number
updateDefaultSats: (sats: number) => void
defaultZapComment: string
@@ -24,6 +30,29 @@ export function ZapProvider({ children }: { children: React.ReactNode }) {
const [defaultZapSats, setDefaultZapSats] = useState
(storage.getDefaultZapSats())
const [defaultZapComment, setDefaultZapComment] = useState(storage.getDefaultZapComment())
const [quickZap, setQuickZap] = useState(storage.getQuickZap())
+ const [isWalletConnected, setIsWalletConnected] = useState(false)
+ const [provider, setProvider] = useState(null)
+ const [walletInfo, setWalletInfo] = useState(null)
+
+ useEffect(() => {
+ const unSubOnConnected = onConnected((provider) => {
+ setIsWalletConnected(true)
+ setWalletInfo(null)
+ setProvider(provider)
+ lightningService.provider = provider
+ provider.getInfo().then(setWalletInfo)
+ })
+ const unSubOnDisconnected = onDisconnected(() => {
+ setIsWalletConnected(false)
+ setProvider(null)
+ lightningService.provider = null
+ })
+
+ return () => {
+ unSubOnConnected()
+ unSubOnDisconnected()
+ }
+ }, [])
const updateDefaultSats = (sats: number) => {
storage.setDefaultZapSats(sats)
@@ -43,6 +72,9 @@ export function ZapProvider({ children }: { children: React.ReactNode }) {
return (
},
{ path: '/settings/translation', element: },
{ path: '/profile-editor', element: },
- { path: '/mutes', element: }
+ { path: '/mutes', element: },
+ { path: '/rizful', element: }
]
export const routes = ROUTES.map(({ path, element }) => ({
diff --git a/src/services/lightning.service.ts b/src/services/lightning.service.ts
index b316c47d..924b1518 100644
--- a/src/services/lightning.service.ts
+++ b/src/services/lightning.service.ts
@@ -1,12 +1,7 @@
import { BIG_RELAY_URLS, CODY_PUBKEY, JUMBLE_PUBKEY } from '@/constants'
import { getZapInfoFromEvent } from '@/lib/event-metadata'
import { TProfile } from '@/types'
-import {
- init,
- launchPaymentModal,
- onConnected,
- onDisconnected
-} from '@getalby/bitcoin-connect-react'
+import { init, launchPaymentModal } from '@getalby/bitcoin-connect-react'
import { Invoice } from '@getalby/lightning-tools'
import { bech32 } from '@scure/base'
import { WebLNProvider } from '@webbtc/webln-types'
@@ -23,7 +18,7 @@ const OFFICIAL_PUBKEYS = [JUMBLE_PUBKEY, CODY_PUBKEY]
class LightningService {
static instance: LightningService
- private provider: WebLNProvider | null = null
+ provider: WebLNProvider | null = null
private recentSupportersCache: TRecentSupporter[] | null = null
constructor() {
@@ -33,12 +28,6 @@ class LightningService {
appName: 'Jumble',
showBalance: false
})
- onConnected((provider) => {
- this.provider = provider
- })
- onDisconnected(() => {
- this.provider = null
- })
}
return LightningService.instance
}
diff --git a/src/services/local-storage.service.ts b/src/services/local-storage.service.ts
index 9a835030..c04f3954 100644
--- a/src/services/local-storage.service.ts
+++ b/src/services/local-storage.service.ts
@@ -47,6 +47,7 @@ class LocalStorageService {
private hideContentMentioningMutedUsers: boolean = false
private notificationListStyle: TNotificationStyle = NOTIFICATION_LIST_STYLE.DETAILED
private mediaAutoLoadPolicy: TMediaAutoLoadPolicy = MEDIA_AUTO_LOAD_POLICY.ALWAYS
+ private shownCreateWalletGuideToastPubkeys: Set = new Set()
constructor() {
if (!LocalStorageService.instance) {
@@ -185,6 +186,13 @@ class LocalStorageService {
this.mediaAutoLoadPolicy = mediaAutoLoadPolicy as TMediaAutoLoadPolicy
}
+ const shownCreateWalletGuideToastPubkeysStr = window.localStorage.getItem(
+ StorageKey.SHOWN_CREATE_WALLET_GUIDE_TOAST_PUBKEYS
+ )
+ this.shownCreateWalletGuideToastPubkeys = shownCreateWalletGuideToastPubkeysStr
+ ? new Set(JSON.parse(shownCreateWalletGuideToastPubkeysStr))
+ : new Set()
+
// Clean up deprecated data
window.localStorage.removeItem(StorageKey.ACCOUNT_PROFILE_EVENT_MAP)
window.localStorage.removeItem(StorageKey.ACCOUNT_FOLLOW_LIST_EVENT_MAP)
@@ -453,6 +461,21 @@ class LocalStorageService {
this.mediaAutoLoadPolicy = policy
window.localStorage.setItem(StorageKey.MEDIA_AUTO_LOAD_POLICY, policy)
}
+
+ hasShownCreateWalletGuideToast(pubkey: string) {
+ return this.shownCreateWalletGuideToastPubkeys.has(pubkey)
+ }
+
+ markCreateWalletGuideToastAsShown(pubkey: string) {
+ if (this.shownCreateWalletGuideToastPubkeys.has(pubkey)) {
+ return
+ }
+ this.shownCreateWalletGuideToastPubkeys.add(pubkey)
+ window.localStorage.setItem(
+ StorageKey.SHOWN_CREATE_WALLET_GUIDE_TOAST_PUBKEYS,
+ JSON.stringify(Array.from(this.shownCreateWalletGuideToastPubkeys))
+ )
+ }
}
const instance = new LocalStorageService()