Time aware message collapsing

So messages across time dont get clumped together as one
This commit is contained in:
Jeremy Zhang 2018-02-05 11:37:46 +00:00
parent 0235197514
commit 1d2a94ce1a

View File

@ -1098,6 +1098,7 @@
if (replace == null) { if (replace == null) {
$("#chatcontent").append(rendered); $("#chatcontent").append(rendered);
handle_last_message_mention(); handle_last_message_mention();
$("#chatcontent p:last-child").attr("timestamp", message.timestamp);
$("#chatcontent p:last-child").find(".blockcode").find("br").remove(); // Remove excessive breaks in codeblocks $("#chatcontent p:last-child").find(".blockcode").find("br").remove(); // Remove excessive breaks in codeblocks
render_code_highlighting($("#chatcontent p:last-child").find(".blockcode")); render_code_highlighting($("#chatcontent p:last-child").find(".blockcode"));
$("#chatcontent .chatusername").last().click(function () { $("#chatcontent .chatusername").last().click(function () {
@ -1258,7 +1259,7 @@
for (var i = 1; i < allMessages.length; i++) { for (var i = 1; i < allMessages.length; i++) {
var last = $(allMessages[i - 1]); var last = $(allMessages[i - 1]);
var current = $(allMessages[i]); var current = $(allMessages[i]);
if (last.attr("discord_userid") == current.attr("discord_userid") && current.attr("discord_userid")) { if (last.attr("discord_userid") == current.attr("discord_userid") && current.attr("discord_userid") && moment(current.attr("timestamp")).isSame(moment(last.attr("timestamp")), "hour")) {
current.addClass("collapsed"); current.addClass("collapsed");
} else { } else {
current.removeClass("collapsed"); current.removeClass("collapsed");