ChatKit icon indicating copy to clipboard operation
ChatKit copied to clipboard

Sorting messages

Open dekanako opened this issue 5 years ago • 1 comments

Hey guys, I want to sort the messages by Timestamp I know that I can sort the collection before adding it to the adapter but my problem is when I want to add a single message to the adapter that's already populated with data

thanks in advance

dekanako avatar Aug 16 '20 16:08 dekanako

If you know that the single message is the last message, you can add simply it to the messages adapter: messagesAdapter.addToStart(message, true);

For me personally, whenever I retrieve a message, each message is added to an ArrayList (messages), sorted (by sorting the collection), then clearing the adapter before adding the messages to the adapter as such: messagesAdapter.addToEnd(messages, true);

If you find a better way, do share it! Cheers

mechdon avatar Sep 29 '21 13:09 mechdon