From 2b68179a82a7e2aa89aa4642c276bd0d9463e27b Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Fri, 20 Oct 2017 06:50:48 +0000 Subject: [PATCH] Collapse messages if the previous is sent by the same author --- webapp/titanembeds/static/css/embedstyle.css | 13 ++++++++++++- webapp/titanembeds/static/js/embed.js | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/webapp/titanembeds/static/css/embedstyle.css b/webapp/titanembeds/static/css/embedstyle.css index c09a320..11a3ee1 100644 --- a/webapp/titanembeds/static/css/embedstyle.css +++ b/webapp/titanembeds/static/css/embedstyle.css @@ -145,6 +145,7 @@ nav .brand-logo { padding-left: 1%; padding-top: 1%; padding-bottom: 40px; + margin-bottom: 13px; /* https://css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/ */ /* These are technically the same, but use both */ @@ -174,7 +175,17 @@ nav .brand-logo { width: 90%; border-top: solid 1px rgba(0, 0, 0, 0.1); padding-top: 10px; - margin-bottom: 11px; + margin-bottom: 0; +} + +#chatcontent > p.collapsed { + border-top: none; + margin-top: 0; + padding-top: 0; +} + +#chatcontent > p.collapsed > .chattimestamp, #chatcontent > p.collapsed > .chatusername, #chatcontent > p.collapsed > .authoravatar { + display: none; } #chatcontent .chatusername { diff --git a/webapp/titanembeds/static/js/embed.js b/webapp/titanembeds/static/js/embed.js index bcc975e..844d013 100644 --- a/webapp/titanembeds/static/js/embed.js +++ b/webapp/titanembeds/static/js/embed.js @@ -901,7 +901,7 @@ jumpscroll = true; } else { fet = fetch(channel_id, last_message_id); - jumpscroll = element_in_view($('#discordmessage_'+last_message_id), true); + jumpscroll = element_in_view($('#discordmessage_'+last_message_id).parent(), true); } fet.done(function(data) { var status = data.status; @@ -963,6 +963,7 @@ } } + collapse_messages(); } function process_message_users_cache_helper(key, usr) { @@ -981,6 +982,19 @@ } } } + + function collapse_messages() { + var allMessages = $('[id^="discordmessage_"]').parent(); + 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.addClass("collapsed"); + } else { + current.removeClass("collapsed"); + } + } + } function update_embed_userchip(authenticated, avatar, username, nickname, userid, discrim=null) { if (authenticated) { @@ -1224,7 +1238,7 @@ if (selected_channel != thismsgchan) { return; } - var jumpscroll = element_in_view($('#discordmessage_'+last_message_id), true); + var jumpscroll = element_in_view($('#discordmessage_'+last_message_id).parent(), true); last_message_id = fill_discord_messages([msg], jumpscroll); });