Hello,
Want to open this up since I have another query on the data structure and how to process them to save the amount of read to Firestore. Currently in my Chat App I display message in each chat with an increment of 10, that's mean I display the 10 newest messages first and if the user scroll up it will display the previous 10 messages before that and so on. I also save the user data of the members of the Group locally the first time a user enter the chat so that when displaying a message it can also show the sender information along with it (like name and profile picture).
The members data is stored in an Array of Map as a field of a Group Document in Firestore, if a member leave the group their data is still store but their isActive field in the Map would change to false, indicating they have left the group and not shown in the group Members list for other user. Doing this can help display their info for their old message if other user read them. In a short term this would be fine, but in a long term, supposely if a group have added 1000 members but only have around 100 currently active member in the group, if a new user join or added to the group they would be pulling 1000 documents from Firestore. If multiple users do that then it will increase the number of read by a lot, and not all of them would check old messages from users who have left.
So I thought of only getting user information for members of the group from the messages that is currently display, and if an user scroll up and encounter a message that has user info not get and store locally, it will get them and store them locally so next time they won't need to. This could reduce the amount of read needed to display user info along with the messages but that also might result in longer load time to display previous message. I am not sure if this is a better way than what I currently have now so can anyone give me some pointer or recommendation?