commit 0e84e3c3f0ea883c3a836fe4f514909e5679e3d1
parent be47e3e81ed10785bee80fd08dbba54d5295aaea
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 19 Jun 2023 06:50:34 -0700
do not show prev/next buttons when no stats
Diffstat:
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go
@@ -346,7 +346,9 @@ func ChessGameStatsHandler(c echo.Context) error {
moveIdx := currMoveIdx
var stats *interceptors.AnalyzeResult
- _ = json.Unmarshal(g.DbChessGame.Stats, &stats)
+ if err := json.Unmarshal(g.DbChessGame.Stats, &stats); err != nil {
+ return c.Redirect(http.StatusFound, c.Request().Referer())
+ }
if c.Request().Method == http.MethodPost {
moveIdxStr := c.Request().PostFormValue("move_idx")
@@ -406,6 +408,9 @@ func ChessGameFormHandler(c echo.Context) error {
isFlipped := g.IsBlack(authUser.ID)
if game.Outcome() != chess.NoOutcome {
+ if g.DbChessGame.Stats == nil {
+ return c.NoContent(http.StatusOK)
+ }
htmlTmpl := `
<style>
button {