mirror of
https://github.com/thelounge/thelounge
synced 2024-11-22 20:13:07 +00:00
Fix #1883: message gaps when reconnecting
This commit is contained in:
parent
5490235f4d
commit
6377e0de66
1 changed files with 7 additions and 5 deletions
|
@ -151,16 +151,18 @@ Chan.prototype.getFilteredClone = function(lastActiveChannel, lastMessage) {
|
|||
// Do not send users, client requests updated user list whenever needed
|
||||
newChannel[prop] = [];
|
||||
} else if (prop === "messages") {
|
||||
// If channel is active, send up to 100 last messages, for all others send just 1
|
||||
// Client will automatically load more messages whenever needed based on last seen messages
|
||||
const messagesToSend = lastActiveChannel === true || this.id === lastActiveChannel ? -100 : -1;
|
||||
|
||||
// If client is reconnecting, only send new messages that client has not seen yet
|
||||
if (lastMessage > -1) {
|
||||
// When reconnecting, always send up to 100 messages to prevent message gaps on the client
|
||||
// See https://github.com/thelounge/lounge/issues/1883
|
||||
newChannel[prop] = this[prop]
|
||||
.filter((m) => m.id > lastMessage)
|
||||
.slice(messagesToSend);
|
||||
.slice(-100);
|
||||
} else {
|
||||
// If channel is active, send up to 100 last messages, for all others send just 1
|
||||
// Client will automatically load more messages whenever needed based on last seen messages
|
||||
const messagesToSend = lastActiveChannel === true || this.id === lastActiveChannel ? -100 : -1;
|
||||
|
||||
newChannel[prop] = this[prop].slice(messagesToSend);
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue