mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 04:23:13 +00:00
Merge pull request #1598 from thelounge/xpaw/fix-863
Synchronize unread marker when other client opens a channel
This commit is contained in:
commit
ded79a184d
1 changed files with 19 additions and 1 deletions
|
@ -3,9 +3,27 @@
|
|||
const $ = require("jquery");
|
||||
const socket = require("../socket");
|
||||
|
||||
// Sync unread badge and marker when other clients open a channel
|
||||
socket.on("open", function(id) {
|
||||
// Another client opened the channel, clear the unread counter
|
||||
if (id < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
const channel = $("#chat #chan-" + id);
|
||||
|
||||
// Don't do anything if the channel is active on this client
|
||||
if (channel.length === 0 || channel.hasClass("active")) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the unread badge
|
||||
$("#sidebar").find(".chan[data-id='" + id + "'] .badge")
|
||||
.removeClass("highlight")
|
||||
.empty();
|
||||
|
||||
// Move unread marker to the bottom
|
||||
channel
|
||||
.find(".unread-marker")
|
||||
.data("unread-id", 0)
|
||||
.appendTo(channel.find(".messages"));
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue