commit 4cbe2f98f9f22a29b71b04c45a37f99f2ec59a45
parent f4564e81f2a57ce4383b5959f0e9491d5cfe3ee9
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Tue, 23 May 2023 19:19:22 -0700
manual refresh popup for stream
Diffstat:
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -4901,8 +4901,16 @@ func ChatStreamMessagesHandler(c echo.Context) error {
data := v1.ChatMessagesData{}
data.ChatMenuData.RoomName = room.Name
- data.ManualRefreshTimeout = 0
+ data.ManualRefreshTimeout = 30
_, _ = c.Response().Write([]byte(v1.GenerateStyle(authUser, data)))
+ _, _ = c.Response().Write([]byte(fmt.Sprintf(`
+ <div id="manualrefresh">
+ <h4>Manual refresh required</h4>
+ <form method="get">
+ <input type="submit" value="Reload" />
+ </form>
+ </div>`)))
+ _, _ = c.Response().Write([]byte(`<div id="http-alive-indicator"></div>`))
_, _ = c.Response().Write([]byte(fmt.Sprintf(`<div style="display:flex;flex-direction:column-reverse;" id="msgs">`)))
c.Response().Flush()
@@ -4918,7 +4926,6 @@ func ChatStreamMessagesHandler(c echo.Context) error {
bools = append(bools, authUser.DisplayHellbanButton, authUser.DisplayKickButton)
}
data.NbButtons = utils.CountBools(bools...)
- _, _ = c.Response().Write([]byte(`<div id="http-alive-indicator"></div>`))
_, _ = c.Response().Write([]byte("<div>" + v1.RenderMessages(authUser, data, csrf, config.NullUsername) + "</div>"))
c.Response().Flush()
@@ -4948,7 +4955,13 @@ Loop:
db.UpdateChatReadRecord(authUser.ID, room.ID)
_, _ = c.Response().Write([]byte(`<style>#http-alive-indicator{background-color:` + clrs[clrIdx%len(clrs)] + `;}</style>`))
+ _, _ = c.Response().Write([]byte(`<style>#manualrefresh{animation: none;}</style>`))
c.Response().Flush()
+ utils.SGo(func() {
+ time.Sleep(10 * time.Millisecond)
+ _, _ = c.Response().Write([]byte(`<style>#manualrefresh{animation: timeout_messages 30s forwards;}</style>`))
+ c.Response().Flush()
+ })
clrIdx++
_, msgTyp, err := sub.ReceiveTimeout(5 * time.Second)