Skip to content

Commit

Permalink
Move invoice script into x-init, increase check interval
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Jun 25, 2024
1 parent 53c957a commit 2370e4d
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions resources/views/livewire/modals/invoice.blade.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@

<script>
document.addEventListener('livewire:load', function () {
// Set up the interval to call checkInvoiceStatus every 1000ms
var intervalId = setInterval(function () {
@this.call('checkInvoiceStatus');
}, 1000);

// Listen for the Livewire 'hook' for component destruction
@this.on('hook:destroyed', function () {
clearInterval(intervalId);
});
<div
x-data="{}" x-init="
const intervalId = setInterval(() => {
@this.call('checkInvoiceStatus');
}, 5000);
@this.on('hook:destroyed', () => {
clearInterval(intervalId);
});
</script>
<div class="p-4" class="p-4 w-full flex-col items-center justify-center">
"
class="p-4 w-full flex-col items-center justify-center">



Expand All @@ -26,4 +24,3 @@
@click="window.webln?window.webln.enable().then(()=>window.webln.sendPayment('{{$invoice}}')):window.open(`lightning:{{$invoice}}`);"
>Pay with app</x-secondary-button>
</div>

0 comments on commit 2370e4d

Please sign in to comment.