dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 6003577edb16ec0a4c11109c6acc49ba68daf475
parent 498b2af94a7c26af859b53d8cec1af5a545a7256
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Mon, 12 Jun 2023 01:17:39 -0700

improve ux

Diffstat:
Mpkg/web/handlers/handlers.go | 10++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -5081,17 +5081,19 @@ func ChessGameHandler(c echo.Context) error { blackQueenSideRookID = "img_56" ) - go func(c echo.Context) { + go func(c echo.Context, key string, p1ID, p2ID database.UserID) { p1Online := false p2Online := false + var once utils.Once for { select { + case <-once.After(100 * time.Millisecond): case <-time.After(5 * time.Second): case <-quit: return } - p1Count := usersStreamsManager.GetUserStreamsCountFor(g.Player1.ID, key) - p2Count := usersStreamsManager.GetUserStreamsCountFor(g.Player2.ID, key) + p1Count := usersStreamsManager.GetUserStreamsCountFor(p1ID, key) + p2Count := usersStreamsManager.GetUserStreamsCountFor(p2ID, key) if p1Online && p1Count == 0 { p1Online = false send(`<style>#p1Status { background-color: darkred !important; }</style>`) @@ -5108,7 +5110,7 @@ func ChessGameHandler(c echo.Context) error { } c.Response().Flush() } - }(c) + }(c, key, g.Player1.ID, g.Player2.ID) i := 0 Loop: