dkforest

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

commit b5560d8ef9b7a904c19cb40e916dd0239d6fa483
parent a236b8d07abf80abca8a4ff61d4aba09def5d7f2
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Fri, 21 Feb 2025 23:26:50 -0800

cleanup

Diffstat:
Mpkg/web/handlers/api/v1/topBarHandler.go | 12+++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/pkg/web/handlers/api/v1/topBarHandler.go b/pkg/web/handlers/api/v1/topBarHandler.go @@ -177,14 +177,12 @@ func ChatTopBarHandler(c echo.Context) error { // GET requests stops here if c.Request().Method != http.MethodPost { if authUser.UseStreamTopBar { - streamItem, err := stream.SetStreaming(c, authUser.ID, "") - if err != nil { - return c.Redirect(http.StatusFound, "/") + if streamItem, err := stream.SetStreaming(c, authUser.ID, ""); err == nil { + defer streamItem.Cleanup() + _, _ = c.Response().Write([]byte(RenderTopBar(csrf, data, authUser))) + c.Response().Flush() + <-streamItem.Quit } - defer streamItem.Cleanup() - _, _ = c.Response().Write([]byte(RenderTopBar(csrf, data, authUser))) - c.Response().Flush() - <-streamItem.Quit return c.NoContent(http.StatusOK) } return c.Render(http.StatusOK, "chat-top-bar", data)