From 249b32e86afb6dc07a4eb4e82b609644bfc215c2 Mon Sep 17 00:00:00 2001 From: nove-b Date: Sun, 24 May 2026 15:44:54 +0900 Subject: [PATCH] appview: clear signup error message on successful signup Signed-off-by: nove-b --- appview/pages/htmx.go | 13 +++++++++++++ appview/signup/signup.go | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/appview/pages/htmx.go b/appview/pages/htmx.go index 059e28bf..0f6b14ae 100644 --- a/appview/pages/htmx.go +++ b/appview/pages/htmx.go @@ -4,6 +4,7 @@ import ( "fmt" "html" "net/http" + "strings" ) // Notice performs a hx-oob-swap to replace the content of an element with a message. @@ -25,6 +26,18 @@ func (s *Pages) NoticeHTML(w http.ResponseWriter, id string, trustedHTML string) w.Write([]byte(markup)) } +func (s *Pages) NoticeHTMLWithClears(w http.ResponseWriter, id string, trustedHTML string, clearIDs ...string) { + var b strings.Builder + b.WriteString(fmt.Sprintf(`%s`, id, trustedHTML)) + for _, clearID := range clearIDs { + b.WriteString(fmt.Sprintf(``, clearID)) + } + + w.Header().Set("Content-Type", "text/html") + w.WriteHeader(http.StatusOK) + w.Write([]byte(b.String())) +} + // HxRefresh is a client-side full refresh of the page. func (s *Pages) HxRefresh(w http.ResponseWriter) { w.Header().Set("HX-Refresh", "true") diff --git a/appview/signup/signup.go b/appview/signup/signup.go index fb52f7a5..ee51d402 100644 --- a/appview/signup/signup.go +++ b/appview/signup/signup.go @@ -332,9 +332,9 @@ func (s *Signup) executeSignupTransaction(ctx context.Context, username, passwor // if we get here, we've successfully created the account and added the email success = true - s.pages.NoticeHTML(w, "signup-msg", fmt.Sprintf(`Account created successfully. You can now + s.pages.NoticeHTMLWithClears(w, "signup-msg", fmt.Sprintf(`Account created successfully. You can now login - with %s.tngl.sh.`, username)) + with %s.tngl.sh.`, username), "signup-error") // clean up inflight signup asynchronously go func() { -- 2.51.2