Collapse messages if the previous is sent by the same author

This commit is contained in:
Jeremy Zhang 2017-10-20 06:50:48 +00:00
parent bee067f8ec
commit 2b68179a82
2 changed files with 28 additions and 3 deletions

View File

@ -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 {

View File

@ -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);
});