Change more to use id rather than count.
This commit is contained in:
parent
f88d1e3bef
commit
e01e21cdbe
@ -693,11 +693,12 @@ $(function() {
|
||||
|
||||
chat.on("click", ".show-more-button", function() {
|
||||
var self = $(this);
|
||||
var count = self.parent().next(".messages").children(".msg").length;
|
||||
var lastMessage = self.parent().next(".messages").children(".msg").first();
|
||||
var lastMessageId = parseInt(lastMessage[0].id.replace("msg-", ""), 10);
|
||||
self.prop("disabled", true);
|
||||
socket.emit("more", {
|
||||
target: self.data("id"),
|
||||
count: count
|
||||
lastId: lastMessageId
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -383,8 +383,8 @@ Client.prototype.more = function(data) {
|
||||
return;
|
||||
}
|
||||
var chan = target.chan;
|
||||
var count = chan.messages.length - (data.count || 0);
|
||||
var messages = chan.messages.slice(Math.max(0, count - 100), count);
|
||||
var index = chan.messages.findIndex((val) => val.id === data.lastId);
|
||||
var messages = chan.messages.slice(Math.max(0, index - 100), index);
|
||||
client.emit("more", {
|
||||
chan: chan.id,
|
||||
messages: messages
|
||||
|
Loading…
Reference in New Issue
Block a user