From 1d2a94ce1a7af818a895828b52cab37b0d02c98e Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Mon, 5 Feb 2018 11:37:46 +0000 Subject: [PATCH] Time aware message collapsing So messages across time dont get clumped together as one --- webapp/titanembeds/static/js/embed.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index 8e6cd56..8b0a9cd 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -1098,6 +1098,7 @@ if (replace == null) { $("#chatcontent").append(rendered); 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 render_code_highlighting($("#chatcontent p:last-child").find(".blockcode")); $("#chatcontent .chatusername").last().click(function () { @@ -1258,7 +1259,7 @@ for (var i = 1; i < allMessages.length; i++) { var last = $(allMessages[i - 1]); 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"); } else { current.removeClass("collapsed");