I’m working on migrating an app that had been based on Firebase to XMPP backed by Mongoose on the server side and using Smack (v 4.3.0) on the Android side. I am trying to build a chat list screen that looks something like facebook messenger’s seen here https://icdn2.digitaltrends.com/image/facebook-messenger-holiday-update-1-720x720.jpg?ver=1.jpg
Since I’m migrating, I have a lot of users with large roster lists and moderate message exchanges, so the initial sync performance is an issue. Currently once I get the roster I loop through all the entries and query for their most recent message, but if a user has 1000 members on their roster, that would be 1000 queries to the server, which is extremely slow. I already do prioritize one group of users (active) over the rest of the users (inactive) but if that active list is long it doesn’t make much of a difference.
I have considered updating the server to allow pages of 1000 messages to be sent back instead of 50 in which case I could just query a user’s entire message history. This would be faster in the case that the user has less than 1000 messages per person on their roster. However, there would be no guarantee that we would have a single message for each person in the roster without querying the entire history since one roster member could have sent only 1 message and it was the first message ever received. So this solution would be a lot of data use and could fill up a user’s phone pretty quickly if they don’t have a lot of disk space.
Is there any other way to populate a chat list screen that shows the most recent message? Ideally I want a query that is something similar to “return 1 message for each JID in the given JID list”.