Skip to content

Commit

Permalink
Merge pull request thelounge#1132 from PolarizedIons/fix-datemarker
Browse files Browse the repository at this point in the history
Fix date-marker not being removed on loading new messages
  • Loading branch information
xPaw authored May 5, 2017
2 parents e14efa5 + 161935f commit 99a5706
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions client/js/lounge.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,21 +469,21 @@ $(function() {
.find("#chan-" + data.chan)
.find(".messages");

// get the scrollable wrapper around messages
var scrollable = chan.closest(".chat");
var heightOld = chan.height();
chan.prepend(documentFragment).end();

// Remove the date-change marker we put at the top, because it may
// not actually be a date change now
var children = $(chan).children();
if (children.eq(0).hasClass("date-marker")) { // Check top most child
if (children.eq(0).hasClass("date-marker-container")) { // Check top most child
children.eq(0).remove();
} else if (children.eq(0).hasClass("unread-marker") && children.eq(1).hasClass("date-marker")) {
// Otherwise the date-marker would get 'stuck' because of the new-message marker
} else if (children.eq(1).hasClass("date-marker-container")) {
// The unread-marker could be at index 0, which will cause the date-marker to become "stuck"
children.eq(1).remove();
}

// get the scrollable wrapper around messages
var scrollable = chan.closest(".chat");
var heightOld = chan.height();
chan.prepend(documentFragment).end();

// restore scroll position
var position = chan.height() - heightOld;
scrollable.scrollTop(position);
Expand Down Expand Up @@ -1364,8 +1364,8 @@ $(function() {

// Remove date-seperators that would otherwise be "stuck" at the top
// of the channel
chan.find(".date-marker").each(function() {
if ($(this).next().hasClass("date-marker")) {
chan.find(".date-marker-container").each(function() {
if ($(this).next().hasClass("date-marker-container")) {
$(this).remove();
}
});
Expand All @@ -1376,7 +1376,7 @@ $(function() {
function clear() {
chat.find(".active")
.find(".show-more").addClass("show").end()
.find(".messages .msg, .date-marker").remove();
.find(".messages .msg, .date-marker-container").remove();
}

function completeNicks(word) {
Expand Down

0 comments on commit 99a5706

Please sign in to comment.