abldxtr001
abldxtr001•2mo ago

implement optimistic updates for a paginated query

How can we implement optimistic updates for a paginated query? Does anyone have an example?
7 Replies
Convex Bot
Convex Bot•2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
abldxtr001
abldxtr001OP•2mo ago
In the end, it turns out that you cannot add anything to a paginated query; you can only modify the existing data, and that's it.😕
erquhart
erquhart•2mo ago
Yeah currently If you can share a little more on your use case or what you're trying to do, there may be a creative workaround.
abldxtr001
abldxtr001OP•2mo ago
A chatroom where you want to show a loading indicator for a new message being sent to the server, implement a load more feature, and other functionalities.
erquhart
erquhart•2mo ago
Pasginated queries already support load more and loading status. For optimistically updating, I would use react state to show sent messages while awaiting the mutation.
abldxtr001
abldxtr001OP•2mo ago
Yes, initially, I implemented a paginated query for loading more, but I faced issues with optimistic updates. So, I switched to a normal query that takes two arguments, take and limit, which made implementing optimistic updates easier. Regarding your suggestion, could you provide an example code? For instance, handling the case of sending multiple messages in a short period.

Did you find this page helpful?