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

+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}
/>