commit 9f0fb3ce0bea8f955813c144c8faaac596724d90
parent 616c0cb4914f788717e0832897829a67e8e543b1
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Wed, 24 May 2023 07:49:33 -0700
reduce bandwidth usage
Diffstat:
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/pkg/web/handlers/api/v1/messages.qtpl b/pkg/web/handlers/api/v1/messages.qtpl
@@ -188,7 +188,7 @@
.mt-10px { margin-top: 10px; }
.notif, .notif:hover { color: #e74c3c; }
#msg-err { background-color: #8f2d2d; color: #ffffff; padding: 1px 5px 2px 5px; display: block; text-decoration: none; }
- #http-alive-indicator {
+ #i {
background-color: #006400;
width: 18px;
height: 18px;
diff --git a/pkg/web/handlers/api/v1/messages.qtpl.go b/pkg/web/handlers/api/v1/messages.qtpl.go
@@ -254,7 +254,7 @@ func StreamGenerateStyle(qw422016 *qt422016.Writer, AuthUser *database.User, Dat
.mt-10px { margin-top: 10px; }
.notif, .notif:hover { color: #e74c3c; }
#msg-err { background-color: #8f2d2d; color: #ffffff; padding: 1px 5px 2px 5px; display: block; text-decoration: none; }
- #http-alive-indicator {
+ #i {
background-color: #006400;
width: 18px;
height: 18px;
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -4971,7 +4971,7 @@ func ChatStreamMessagesHandler(c echo.Context) error {
data.ChatMenuData.RoomName = room.Name
data.ManualRefreshTimeout = 0
_, _ = c.Response().Write([]byte(v1.GenerateStyle(authUser, data)))
- _, _ = c.Response().Write([]byte(`<div id="http-alive-indicator"></div>`))
+ _, _ = c.Response().Write([]byte(`<div id="i"></div>`)) // http alive indicator; green/red dot
_, _ = c.Response().Write([]byte(fmt.Sprintf(`<div style="display:flex;flex-direction:column-reverse;" id="msgs">`)))
c.Response().Flush()
@@ -5011,7 +5011,8 @@ Loop:
// Update read record
db.UpdateChatReadRecord(authUser.ID, room.ID)
- _, _ = c.Response().Write([]byte(fmt.Sprintf(`<style>#http-alive-indicator{background-color:#008000;animation: %s 10s forwards;}</style>`,
+ // Toggle the "http alive indicator" class to keep the dot green
+ _, _ = c.Response().Write([]byte(fmt.Sprintf(`<style>#i{animation: %s 10s forwards}</style>`,
utils.Ternary(indicatorSelector, "indicator1", "indicator2"))))
c.Response().Flush()
indicatorSelector = !indicatorSelector