Fix unread marker being off by one on the server
This commit is contained in:
parent
0e7880a049
commit
c70b4d4c80
@ -47,7 +47,7 @@ socket.on("msg", function(data) {
|
||||
channel.messages.push(data.msg);
|
||||
|
||||
if (data.msg.self) {
|
||||
channel.firstUnread = channel.messages[channel.messages.length - 1].id;
|
||||
channel.firstUnread = data.msg.id;
|
||||
} else {
|
||||
notifyMessage(targetId, channel, vueApp.activeChannel, data.msg);
|
||||
}
|
||||
|
@ -21,8 +21,11 @@ socket.on("open", function(id) {
|
||||
if (channel) {
|
||||
channel.channel.highlight = 0;
|
||||
channel.channel.unread = 0;
|
||||
|
||||
if (channel.channel.messages.length > 0) {
|
||||
channel.channel.firstUnread = channel.channel.messages[channel.channel.messages.length - 1].id;
|
||||
}
|
||||
}
|
||||
|
||||
utils.updateTitle();
|
||||
});
|
||||
|
@ -422,10 +422,13 @@ Client.prototype.open = function(socketId, target) {
|
||||
return;
|
||||
}
|
||||
|
||||
target.chan.firstUnread = 0;
|
||||
target.chan.unread = 0;
|
||||
target.chan.highlight = 0;
|
||||
|
||||
if (target.chan.messages.length > 0) {
|
||||
target.chan.firstUnread = target.chan.messages[target.chan.messages.length - 1].id;
|
||||
}
|
||||
|
||||
attachedClient.openChannel = target.chan.id;
|
||||
this.lastActiveChannel = target.chan.id;
|
||||
|
||||
|
@ -59,7 +59,7 @@ Chan.prototype.pushMessage = function(client, msg, increasesUnread) {
|
||||
if (msg.self) {
|
||||
// reset counters/markers when receiving self-/echo-message
|
||||
this.unread = 0;
|
||||
this.firstUnread = 0;
|
||||
this.firstUnread = msg.id;
|
||||
this.highlight = 0;
|
||||
} else if (!isOpen) {
|
||||
if (!this.firstUnread) {
|
||||
|
Loading…
Reference in New Issue
Block a user