Compare commits
No commits in common. "test-sse" and "develop" have entirely different histories.
@ -19,7 +19,7 @@ templ Overlay(lnurl string, lnaddr string) {
|
||||
<style id="zap-custom-css"></style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="controls" class="hidden grid grid-cols-[auto_auto] fixed top-0 left-0 items-center gap-3 m-3">
|
||||
<div id="controls" class="hidden grid grid-cols-2 fixed top-0 left-0 items-center gap-3 m-3">
|
||||
<label for="qr-scale-slider" class="text-black">QR code size:</label>
|
||||
<input
|
||||
type="range"
|
||||
@ -40,8 +40,6 @@ templ Overlay(lnurl string, lnaddr string) {
|
||||
value="1.0"
|
||||
class="w-32 accent-teal"
|
||||
/>
|
||||
<label for="stream-url" class="text-black">Stream URL:</label>
|
||||
<a id="stream-url" class="text-sky-600 hover:text-sky-900 underline">click me</a>
|
||||
</div>
|
||||
<div
|
||||
id="zap-container"
|
||||
@ -122,14 +120,14 @@ templ Overlay(lnurl string, lnaddr string) {
|
||||
enableDrag("zap-container", "zapX", "zapY")
|
||||
|
||||
// hide 'zap messages will show up here' if query param given
|
||||
function showControls() {
|
||||
function showHelpers() {
|
||||
document.querySelector('#zap-template').style.display = "flex";
|
||||
document.querySelector('#controls').style.display = "grid";
|
||||
}
|
||||
|
||||
const params = new URLSearchParams(window.location.search)
|
||||
if (!params.has("stream", 1) && (!params.has("config") || params.has("config", 1))) {
|
||||
showControls()
|
||||
if (params.has("help", 1)) {
|
||||
showHelpers()
|
||||
}
|
||||
|
||||
function enableSlider(sliderId, elementId, param, onChange) {
|
||||
@ -145,7 +143,6 @@ templ Overlay(lnurl string, lnaddr string) {
|
||||
clearTimeout(timeout);
|
||||
localStorage.setItem(param, value);
|
||||
onChange(target, value);
|
||||
updateStreamUrl();
|
||||
timeout = setTimeout(() => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
params.set(param, value);
|
||||
@ -210,26 +207,6 @@ templ Overlay(lnurl string, lnaddr string) {
|
||||
}
|
||||
`;
|
||||
})
|
||||
|
||||
function updateStreamUrl() {
|
||||
const params = new URLSearchParams({ stream: 1 });
|
||||
const [qrX,qrY] = localStorage.getItem('qr-position')?.split(',').map(Number) ?? [0,0];
|
||||
params.set("qrX", qrX);
|
||||
params.set("qrY", qrY);
|
||||
const [zapX,zapY] = localStorage.getItem('zap-container-position')?.split(',').map(Number) ?? [0,0];
|
||||
params.set("zapX", zapX);
|
||||
params.set("zapY", zapY);
|
||||
const qrScale = localStorage.getItem('qrScale') ?? 1.0;
|
||||
params.set("qrScale", qrScale);
|
||||
const zapScale = localStorage.getItem('zapScale') ?? 1.0;
|
||||
params.set("zapScale", zapScale);
|
||||
const streamUrl = `${window.location.origin}${window.location.pathname}?${params.toString()}`
|
||||
const element = document.getElementById('stream-url');
|
||||
element.href = streamUrl;
|
||||
element.textContent = '/overlay?' + params.toString();
|
||||
}
|
||||
|
||||
updateStreamUrl();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -53,11 +53,6 @@ func sseHandler(invSrc chan *lightning.Invoice) echo.HandlerFunc {
|
||||
ticker := time.NewTicker(1 * time.Second)
|
||||
defer ticker.Stop()
|
||||
|
||||
i := 0
|
||||
|
||||
ticker2 := time.NewTicker(1 * time.Second)
|
||||
defer ticker2.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-c.Request().Context().Done():
|
||||
@ -71,19 +66,11 @@ func sseHandler(invSrc chan *lightning.Invoice) echo.HandlerFunc {
|
||||
if err := event.MarshalTo(w); err != nil {
|
||||
return err
|
||||
}
|
||||
case <-ticker2.C:
|
||||
case inv := <-invSrc:
|
||||
buf := templ.GetBuffer()
|
||||
defer templ.ReleaseBuffer(buf)
|
||||
|
||||
inv := lightning.Invoice{
|
||||
PaymentHash: fmt.Sprintf("test-%d", i),
|
||||
Description: "test",
|
||||
Msats: 1000,
|
||||
CreatedAt: time.Now(),
|
||||
ConfirmedAt: time.Now(),
|
||||
}
|
||||
|
||||
if err := components.Zap(&inv).Render(c.Request().Context(), buf); err != nil {
|
||||
if err := components.Zap(inv).Render(c.Request().Context(), buf); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -98,12 +85,6 @@ func sseHandler(invSrc chan *lightning.Invoice) echo.HandlerFunc {
|
||||
if err := event.MarshalTo(w); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
i += 1
|
||||
|
||||
if i > 10 {
|
||||
ticker2.Stop()
|
||||
}
|
||||
}
|
||||
w.Flush()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user