From 0aa83227da57ae67ad9d06f1032cebaaff4e8dfa Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Wed, 27 Nov 2024 17:44:38 +0200 Subject: [PATCH] Fixed color issue on the server, made the UI have better UX --- internal/client/ui/core/core.go | 6 +++++- internal/client/ui/core/networkcreation/networkcreation.go | 3 --- internal/server/api/helpers.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/client/ui/core/core.go b/internal/client/ui/core/core.go index fba3ddb..1f86121 100644 --- a/internal/client/ui/core/core.go +++ b/internal/client/ui/core/core.go @@ -144,7 +144,11 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyEnter: if m.networkCreationPopup != nil { - return m, m.networkCreationPopup.Select() + cmd := m.networkCreationPopup.Select() + if cmd != nil { + m.networkCreationPopup = nil + } + return m, cmd } default: diff --git a/internal/client/ui/core/networkcreation/networkcreation.go b/internal/client/ui/core/networkcreation/networkcreation.go index 081c1ce..b7f76d4 100644 --- a/internal/client/ui/core/networkcreation/networkcreation.go +++ b/internal/client/ui/core/networkcreation/networkcreation.go @@ -95,9 +95,6 @@ func New() Model { if strings.TrimSpace(s) == "" { return errors.New("cannot be empty") } - if strings.TrimSpace(s) != s { - return errors.New("no leading/trailing spaces") - } return nil } diff --git a/internal/server/api/helpers.go b/internal/server/api/helpers.go index 967f308..0918e66 100644 --- a/internal/server/api/helpers.go +++ b/internal/server/api/helpers.go @@ -13,7 +13,7 @@ func isValidHexColor(color string) (bool, string) { return false, "color must start with '#'" } - for _, c := range color { + for _, c := range color[1:] { if !strings.ContainsRune(hex, c) { return false, "color must start with '#' and contain exactly 6 digits 0-9, a-f, A-F" }