From 77098472671fd8f0d9eb11b35d1a2c51cbc0cbeb Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Mon, 19 Dec 2016 12:48:54 +0200 Subject: [PATCH] Fix unread marker being removed from DOM --- client/js/lounge.js | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index ab861205..df52b77d 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -1318,26 +1318,14 @@ $(function() { setInterval(function() { chat.find(".chan:not(.active)").each(function() { var chan = $(this); - if (chan.find(".messages .msg:not(.unread-marker)").slice(0, -100).remove().length) { + if (chan.find(".messages .msg").slice(0, -100).remove().length) { chan.find(".show-more").addClass("show"); // Remove date-seperators that would otherwise be "stuck" at the top // of the channel - var prev; - $(chan.find(".messages").children()).each(function() { - if (!prev) { - // Should always be a date-seperator, because it's always added - prev = $(this); - } else { - var current = $(this); - - if (current.attr("class") === "date-marker") { - prev.remove(); - } else { - return false; - } - - prev = current; + chan.find(".date-marker").each(function() { + if ($(this).next().hasClass("date-marker")) { + $(this).remove(); } }); } @@ -1345,9 +1333,9 @@ $(function() { }, 1000 * 10); function clear() { - chat.find(".active .messages .msg:not(.unread-marker)").remove(); - chat.find(".active .show-more").addClass("show"); - chat.find(".active .date-marker").remove(); + chat.find(".active") + .find(".show-more").addClass("show").end() + .find(".messages .msg, .date-marker").remove(); } function complete(word) {