commit e1a1e568b5a53b8a35423299fb5f6a25013d891e
parent 0b2894e403de9bb2b48a22d414876b29591bb38a
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 30 May 2023 18:20:58 -0700
cleanup + doc
Diffstat:
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -5125,13 +5125,22 @@ func ChatStreamMessagesHandler(c echo.Context) error {
displayReadMarker = fstMsgTsRound.Before(readMarkerTsRound) || fstMsgTsRound.Equal(readMarkerTsRound)
}
+ // Keep track of current read-marker revision
readMarkerRev := 0
+ // Hide current rev of read marker and insert an invisible one at the top.
updateReadMarker := func() {
send(fmt.Sprintf(`<style>.read-marker-%d{display:none !important;}</style>`, readMarkerRev))
send(fmt.Sprintf(`<div class="read-marker read-marker-%d" style="display:none;"></div>`, readMarkerRev+1))
readMarkerRev++
displayReadMarker = true
}
+ // Show the invisible read-marker which used to be at the top.
+ showReadMarker := func() {
+ if displayReadMarker {
+ send(fmt.Sprintf(`<style>.read-marker-%d{display:block !important;}</style>`, readMarkerRev))
+ displayReadMarker = false
+ }
+ }
// Toggle between true/false every 5sec. This bool keep track of which class to send for our "online indicator"
// We need to change the css class in order for the css to never actually complete the animation and stay "green".
@@ -5253,10 +5262,7 @@ Loop:
msgsMap[msg.ID] = struct{}{}
send(renderedMsg)
- if displayReadMarker {
- send(fmt.Sprintf(`<style>.read-marker-%d{display:block !important;}</style>`, readMarkerRev))
- displayReadMarker = false
- }
+ showReadMarker()
// Sound notifications
var newMessageSound, taggedSound, pmSound bool