Merge pull request #2236 from thelounge/xpaw/fix-2214

Rework how unread marker is moved when status messages are hidden
This commit is contained in:
Jérémie Astori 2018-03-16 02:15:43 -04:00 committed by GitHub
commit 640d8df487
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -70,12 +70,25 @@ function processReceivedMessage(data) {
notifyMessage(targetId, channel, data); notifyMessage(targetId, channel, data);
const lastVisible = container.find("div:visible").last(); let shouldMoveMarker = data.msg.self;
if (data.msg.self if (!shouldMoveMarker) {
|| lastVisible.hasClass("unread-marker") const lastChild = container.children().last();
|| (lastVisible.hasClass("date-marker")
&& lastVisible.prev().hasClass("unread-marker"))) { // If last element is hidden (e.g. hidden status messages) check the element before it.
// If it's unread marker or date marker, then move unread marker to the bottom
// so that it isn't displayed as the last element in chat.
// display properly is checked instead of using `:hidden` selector because it doesn't work in non-active channels.
if (lastChild.css("display") === "none") {
const prevChild = lastChild.prev();
shouldMoveMarker =
prevChild.hasClass("unread-marker") ||
(prevChild.hasClass("date-marker") && prevChild.prev().hasClass("unread-marker"));
}
}
if (shouldMoveMarker) {
container container
.find(".unread-marker") .find(".unread-marker")
.data("unread-id", 0) .data("unread-id", 0)