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:
commit
640d8df487
@ -70,12 +70,25 @@ function processReceivedMessage(data) {
|
||||
|
||||
notifyMessage(targetId, channel, data);
|
||||
|
||||
const lastVisible = container.find("div:visible").last();
|
||||
let shouldMoveMarker = data.msg.self;
|
||||
|
||||
if (data.msg.self
|
||||
|| lastVisible.hasClass("unread-marker")
|
||||
|| (lastVisible.hasClass("date-marker")
|
||||
&& lastVisible.prev().hasClass("unread-marker"))) {
|
||||
if (!shouldMoveMarker) {
|
||||
const lastChild = container.children().last();
|
||||
|
||||
// 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
|
||||
.find(".unread-marker")
|
||||
.data("unread-id", 0)
|
||||
|
Loading…
Reference in New Issue
Block a user