Fix #1883: message gaps when reconnecting
This commit is contained in:
parent
5490235f4d
commit
6377e0de66
@ -151,16 +151,18 @@ Chan.prototype.getFilteredClone = function(lastActiveChannel, lastMessage) {
|
|||||||
// Do not send users, client requests updated user list whenever needed
|
// Do not send users, client requests updated user list whenever needed
|
||||||
newChannel[prop] = [];
|
newChannel[prop] = [];
|
||||||
} else if (prop === "messages") {
|
} else if (prop === "messages") {
|
||||||
|
// 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(-100);
|
||||||
|
} else {
|
||||||
// If channel is active, send up to 100 last messages, for all others send just 1
|
// 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
|
// Client will automatically load more messages whenever needed based on last seen messages
|
||||||
const messagesToSend = lastActiveChannel === true || this.id === lastActiveChannel ? -100 : -1;
|
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) {
|
|
||||||
newChannel[prop] = this[prop]
|
|
||||||
.filter((m) => m.id > lastMessage)
|
|
||||||
.slice(messagesToSend);
|
|
||||||
} else {
|
|
||||||
newChannel[prop] = this[prop].slice(messagesToSend);
|
newChannel[prop] = this[prop].slice(messagesToSend);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user