Hi forum community - I’ve seen a number of threads w/r/t load issues and/or “scroll to last item” when using a repeating group in a chat. That is, a repeating group in a chat is set to scroll to last item when loaded but gets stuck because it takes too long to load every message. I used a workaround to load the last 5 messages within a chat (shoutout to @eve for the help). Here’s how it looks.
- Each new message is indexed in a message data table (i.e. assigned a number), I call this messageIndex. Looks like this:
- Create a custom state on the page or an invisible group for an index number, like this:
- When page loads or button is clicked to load chat messages set state for your index number as the fifth last messageIndex (from your message data table). I do this by searching first my Chat data table for the relevant chat (defined by the current user and the “chat with” user), then the messages within that chat, and pull the last items messageIndex number minus 5. Like this:
- Lastly, I set the data source for my RG to pull only the last 5 messages of the loaded chat by using “items from #” and the index set in step 3. Looks like this:
The result is that my RG only loads the last 5 messages in a chat.