Do not remove date marker when loading history if date changes
Fixes #2566
This commit is contained in:
parent
a637cb0632
commit
9a808b58e9
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user