From 3e1b50bed700d84253c252aa95598b7ddbf23bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nu=C5=A1a=20Puk=C5=A1i=C4=8D?= Date: Fri, 10 Oct 2025 11:34:43 +0200 Subject: [PATCH] Pass error info --- assets/controllers/login_controller.js | 18 ++++++++++++++++-- templates/components/UserMenu.html.twig | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/assets/controllers/login_controller.js b/assets/controllers/login_controller.js index b73a1cf..a7f4568 100644 --- a/assets/controllers/login_controller.js +++ b/assets/controllers/login_controller.js @@ -2,10 +2,25 @@ import { Controller } from '@hotwired/stimulus'; import { getComponent } from '@symfony/ux-live-component'; export default class extends Controller { + static targets = ['nostrError']; + async initialize() { this.component = await getComponent(this.element); } - async loginAct() { + async loginAct(event) { + if (!window.nostr) { + if (this.hasNostrErrorTarget) { + this.nostrErrorTarget.textContent = 'Extension is not available.'; + this.nostrErrorTarget.style.display = 'block'; + } + event?.preventDefault(); + return; + } + if (this.hasNostrErrorTarget) { + this.nostrErrorTarget.textContent = ''; + this.nostrErrorTarget.style.display = 'none'; + } + const tags = [ ['u', window.location.origin + '/login'], ['method', 'POST'], @@ -35,4 +50,3 @@ export default class extends Controller { } } } - diff --git a/templates/components/UserMenu.html.twig b/templates/components/UserMenu.html.twig index 7131f91..25ac226 100644 --- a/templates/components/UserMenu.html.twig +++ b/templates/components/UserMenu.html.twig @@ -31,6 +31,7 @@