dkforest

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

commit 7281a4c2fddd33596c0c3fd45df54c65e554a7f2
parent d42ee05814e3fc2a2bfd95dd80fd1670162c3c05
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue, 30 May 2023 18:09:03 -0700

Add doc

Diffstat:
Mpkg/web/handlers/handlers.go | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go @@ -5166,6 +5166,8 @@ Loop: continue } + // We receive this event when the "update read-marker" is clicked. + // This means the user is saying that all messages are read, and read-marker should be at the very top. if topic == readMarkerTopic { msgsMap = make(map[int64]struct{}) // read-marker at the top, so no unread message send(fmt.Sprintf(`<style>.read-marker-%d{display:none !important;}</style>`, readMarkerRev)) @@ -5182,6 +5184,8 @@ Loop: } if msgTyp.Typ == database.DeleteMsg { + // Delete msg from the map that keep track of unread messages. + // If the map is now empty, we hide the read-marker. delete(msgsMap, msgTyp.Msg.ID) if len(msgsMap) == 0 { send(fmt.Sprintf(`<style>.read-marker-%d{display:none !important;}</style>`, readMarkerRev)) @@ -5245,6 +5249,7 @@ Loop: isFirstMsg := false renderedMsg := v1.RenderMessage(1, *msg, authUser, data, baseTopBarURL, &readMarkerRendered, &isFirstMsg, csrf, nullUsername) + // Keep track of unread messages msgsMap[msg.ID] = struct{}{} send(renderedMsg)