mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 00:37:23 +00:00
history event listeners to update transactions live
This commit is contained in:
1 parent
2569f0dd0d
commit
7af7aee47c
1 file changed
+38
@@ -560,6 +560,44 @@ export function CashuWallet() {
|
|||||||
}
|
}
|
||||||
}, [isInitialized, historyEntries.length, loadHistory]);
|
}, [isInitialized, historyEntries.length, loadHistory]);
|
||||||
|
|
||||||
|
// Auto-refresh transaction history on new transactions
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isInitialized) return;
|
||||||
|
|
||||||
|
console.log('📜 Setting up history auto-refresh listeners...');
|
||||||
|
|
||||||
|
// Listen for history updates (fires on send, receive transactions)
|
||||||
|
const unsubscribeHistoryUpdated = on('history:updated', () => {
|
||||||
|
console.log('📜 History updated event, refreshing...');
|
||||||
|
loadHistory();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listen for melt quote creation (coco-cashu bug: doesn't emit history:updated)
|
||||||
|
const unsubscribeMeltCreated = on('melt-quote:created', () => {
|
||||||
|
console.log('📜 Melt quote created, refreshing history...');
|
||||||
|
loadHistory();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listen for melt quote paid (backup, in case creation event missed)
|
||||||
|
const unsubscribeMeltPaid = on('melt-quote:paid', () => {
|
||||||
|
console.log('📜 Melt quote paid, refreshing history...');
|
||||||
|
loadHistory();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Listen for mint quote REDEEMED (only after invoice is paid, not created)
|
||||||
|
const unsubscribeMintRedeemed = on('mint-quote:redeemed', () => {
|
||||||
|
console.log('📜 Mint quote redeemed (invoice paid), refreshing history...');
|
||||||
|
loadHistory();
|
||||||
|
});
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
unsubscribeHistoryUpdated();
|
||||||
|
unsubscribeMeltCreated();
|
||||||
|
unsubscribeMeltPaid();
|
||||||
|
unsubscribeMintRedeemed();
|
||||||
|
};
|
||||||
|
}, [isInitialized, on, loadHistory]);
|
||||||
|
|
||||||
// Cleanup mint quote listener on component unmount
|
// Cleanup mint quote listener on component unmount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
Reference in new issue
Block a user