npubxcash lnaddress subscriptions working

This commit is contained in:
lemonknowsall committed 2025-10-16 17:05:39 -07:00
1 parent b5bc571aa7
commit ea57135d1e
4 files changed
+150 -48

No files matched your search

-17
View File
@@ -33,9 +33,6 @@ interface BalanceDisplayProps {
onCopyToClipboard: (text: string) => Promise<void>;
onShowLightningAddressQR: (qrCode: string) => void;
generateQRCode: (text: string) => Promise<string>;
// Refresh functionality
onRefreshQuotes: () => Promise<void>;
isRefreshingQuotes: boolean;
// Dropdown state
mintDropdownOpen: boolean;
setMintDropdownOpen: (open: boolean) => void;
@@ -62,8 +59,6 @@ export function BalanceDisplay({
onCopyToClipboard,
onShowLightningAddressQR,
generateQRCode,
onRefreshQuotes,
isRefreshingQuotes,
mintDropdownOpen,
setMintDropdownOpen,
}: BalanceDisplayProps) {
@@ -98,18 +93,6 @@ export function BalanceDisplay({
>
{convertCurrency(totalBalance, showSats)}
</button>
{/* Refresh Quotes Button */}
{userPubkey && (
<button
onClick={onRefreshQuotes}
disabled={isRefreshingQuotes}
className="flex items-center justify-center p-2 hover:bg-muted rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
title="Refresh quotes from npub.cash"
>
<RefreshCw className={`h-5 w-5 text-muted-foreground ${isRefreshingQuotes ? 'animate-spin' : ''}`} />
</button>
)}
</div>
{/* Main Mode Toggle */}
+20 -2
View File
@@ -48,6 +48,7 @@ export function CashuWallet() {
getUserInfo: getNpubCashUserInfo,
getAllQuotes,
refreshQuotes,
syncQuotesWithWallet,
isLoggedIn: isNpubCashLoggedIn,
isLoading: isNpubCashLoading,
error: npubCashError,
@@ -233,6 +234,25 @@ export function CashuWallet() {
fetchUserInfo();
}, [isNpubCashLoggedIn, isInitialized, isNpubCashLoading, getNpubCashUserInfo, activeMintUrl, mints, coco, setActiveMintUrl]);
// Set up automatic quote sync subscription when logged into npub.cash
useEffect(() => {
if (!isNpubCashLoggedIn || !coco || !isInitialized) return;
let unsubscribe: (() => void) | null = null;
const setupSync = async () => {
unsubscribe = await syncQuotesWithWallet(coco, toast);
};
setupSync();
return () => {
if (unsubscribe) {
unsubscribe();
}
};
}, [isNpubCashLoggedIn, coco, isInitialized, syncQuotesWithWallet, toast]);
// ============================================================================
// EFFECTS - Cleanup
// ============================================================================
@@ -284,8 +304,6 @@ export function CashuWallet() {
setShowLightningAddressQR(true);
}}
generateQRCode={generateQRCode}
onRefreshQuotes={() => refreshQuotes(coco, toast)}
isRefreshingQuotes={isNpubCashLoading}
mintDropdownOpen={mintDropdownOpen}
setMintDropdownOpen={setMintDropdownOpen}
/>