Fix copy button flicker on poll

This commit is contained in:
ekzyis 2024-09-09 00:46:11 +02:00
parent ed9d6f30c4
commit bdc768cb27
1 changed files with 32 additions and 30 deletions

View File

@ -11,8 +11,8 @@ templ Invoice(hash string, bolt11 string, msats int, expiresIn int, paid bool, r
</div>
<div class="my-1">{ format(msats) }</div>
@InvoiceStatus(hash, expiresIn, paid, redirectUrl)
<div class="none" id="bolt11-data" bolt11-data={ templ.JSONString(bolt11) } hx-preserve></div>
<script type="text/javascript" id="bolt11-js" hx-preserve>
<div class="none" id="bolt11-data" bolt11-data={ templ.JSONString(bolt11) }></div>
<script type="text/javascript" id="bolt11-js">
htmx.on("#close", "click", function () {
// abort in-flight polls and prevent new polls
htmx.trigger("#poll", "htmx:abort")
@ -23,6 +23,7 @@ templ Invoice(hash string, bolt11 string, msats int, expiresIn int, paid bool, r
}
templ InvoiceStatus(hash string, expiresIn int, paid bool, redirectUrl templ.SafeURL) {
<div id="status">
if paid {
<div class="font-mono neon success my-1">PAID</div>
<!-- TODO: show timer for redirect -->
@ -68,11 +69,12 @@ templ InvoiceStatus(hash string, expiresIn int, paid bool, redirectUrl templ.Saf
id="poll"
hx-get={ string(templ.SafeURL("/invoice/" + hash)) }
hx-trigger="load delay:1s"
hx-target="#modal"
hx-target="#status"
hx-swap="outerHTML"
hx-select="#modal"
hx-select="#status"
></div>
}
</div>
}
func format(msats int) string {