Merge pull request #2567 from thelounge/xpaw/fix-2566

Do not remove date marker when loading history if date changes
This commit is contained in:
Jérémie Astori 2018-06-17 13:57:21 -04:00 committed by GitHub
commit 511e612e16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,17 +21,24 @@ socket.on("more", function(data) {
return; return;
} }
// Remove the date-change marker we put at the top, because it may // Remove the date marker at the top if date does not change
// not actually be a date change now
const children = $(chan).children(); const children = $(chan).children();
if (children.eq(0).hasClass("date-marker-container")) { // Check top most child // Check the top-most element and the one after because
children.eq(0).remove(); // unread and date markers may switch positions
} else if (children.eq(1).hasClass("date-marker-container")) { for (let i = 0; i <= 1; i++) {
// The unread-marker could be at index 0, which will cause the date-marker to become "stuck" const marker = children.eq(i);
children.eq(1).remove();
} else if (children.eq(0).hasClass("condensed") && children.eq(0).children(".date-marker-container").eq(0).hasClass("date-marker-container")) { if (marker.hasClass("date-marker-container")) {
children.eq(0).children(".date-marker-container").eq(0).remove(); const msgTime = new Date(data.messages[data.messages.length - 1].time);
const prevMsgTime = new Date(marker.data("time"));
if (prevMsgTime.toDateString() === msgTime.toDateString()) {
marker.remove();
}
break;
}
} }
// Add the older messages // Add the older messages