I'm getting a list of the 200 most recent messages in my publish function, like so:
Messages.find({
room: roomname
}, {
sort: {time : -1},
limit: 200
}),
I know this makes the newest first, but I want the oldest first, so when I do the find on the client, I sort the other way:
messages: Messages.find({}, {sort: {time: 1}})
Everything shows up fine except for when I enter a new message. It gets inserted at the end of the list that has all the old messages. After the insert makes its round trip to the server, it jumps to the correct end of the list.
If I take out the limit and client-side sorting, and just give the client all the messages in the correct order, this issue does not occur.
How can I make the message show in the correct place while during the latency compensation?