commit f05cce0db0429481d3702fd48e4e0e03d3330f95
parent 9bcf170abdc10f10f7cf99dbd5b652d95ebdd54a
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 29 May 2023 03:17:40 -0700
add doc
Diffstat:
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -5172,6 +5172,7 @@ Loop:
}
if msgTyp.Typ == database.EditMsg {
+ // Get all messages for the user that were created after the edited one (included)
msgs, err := db.GetChatMessages(room.ID, roomKey, authUser.Username, authUser.ID, pmOnlyQuery,
mentionsOnlyQuery, displayHellbanned, authUser.DisplayIgnored, authUser.DisplayModerators,
displayIgnoredMessages, msgTyp.Msg.ID)
@@ -5179,20 +5180,24 @@ Loop:
return c.Redirect(http.StatusFound, "/")
}
+ // If no messages, continue. This might happen if the user has ignored the user making the edit.
+ if len(msgs) == 0 {
+ c.Response().Flush()
+ continue
+ }
+
+ // Generate css to hide the previous revision of these messages
toHide := make([]string, len(msgs))
for i, msg := range msgs {
toHide[i] = fmt.Sprintf(".msgidc-%s-%d", msg.UUID, msg.Rev-1)
}
send(fmt.Sprintf(`<style>%s{display:none;}</style>`, strings.Join(toHide, ",")))
- if len(msgs) == 0 {
- c.Response().Flush()
- continue
- }
-
+ // Render the new revision of the messages in html
data.Messages = msgs
data.NbButtons = authUser.CountUIButtons()
send(v1.RenderMessages(authUser, data, csrf, nullUsername))
+
c.Response().Flush()
continue
}