From a89946d46bfc4a91ebc7585204bddc65aecd6764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Tue, 11 Jan 2022 15:19:48 -0500 Subject: [PATCH] Fixed #30, validation triggers at a later stage --- tui/helpers.go | 4 ---- tui/mainscreen.go | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tui/helpers.go b/tui/helpers.go index e227065..609616a 100644 --- a/tui/helpers.go +++ b/tui/helpers.go @@ -93,10 +93,6 @@ func (t *TUI) OpenArticle(article *models.Article, readOnly bool) (models.Articl newArticle.Body = strings.TrimSpace(content[1]) - if valid, err := newArticle.IsValid(); valid == false { - return *article, err - } - return newArticle, nil } diff --git a/tui/mainscreen.go b/tui/mainscreen.go index 7ec21c4..713daae 100644 --- a/tui/mainscreen.go +++ b/tui/mainscreen.go @@ -420,6 +420,11 @@ func(mainscreen *Mainscreen) submitNewArticle(group string) { return } + if valid, err := updatedNewArticle.IsValid(); valid == false { + mainscreen.T.ShowErrorModal(err.Error()) + return + } + mainscreen.T.ShowModal( "Do you want to submit this new article?", map[string]ModalButton{ @@ -462,6 +467,11 @@ func(mainscreen *Mainscreen) replyToArticle(article *models.Article) { return } + if valid, err := updatedNewArticle.IsValid(); valid == false { + mainscreen.T.ShowErrorModal(err.Error()) + return + } + mainscreen.T.ShowModal( "Do you want to submit this reply?", map[string]ModalButton{