Custom Messages keep reloading #218
-
I have inserted a widget inside the bubble builder to fetch a Instagram type post. This widget needs to do an API call so its using a future builder right now, but this widget keeps reloading every time the keyboard is opened or closed. Any leads on how can I achieve this functionality? (the functionality I'm trying to achieve is like the ability to share posts or stories in Instagram chat) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Oh.. I'm afraid whatever has the logic inside the bubble will result in this. We had the same problem with a link preview. In the first version a text message had a logic inside to fetch the preview and display it, however it was happening on every reload (when scrolling messages, opening keyboard etc). Our solution was to add a PreviewData parameter to the message itself, and if that parameter was passed - not fetch the preview. I guess the same could be applied to your use case - message is trying to fetch the data (while it is fetching you block any other attempts to fetch), and in the end you either set the data to null and require some button to retry it (and you do not retry automatically, otherwise it will loop) or you will get a success, set the data, and store it somewhere outside the message itself (on the whole chat level) - this way while scrolling and reloading your component will not try to refetch it. |
Beta Was this translation helpful? Give feedback.
-
v2 #646 includes |
Beta Was this translation helpful? Give feedback.
v2 #646 includes
ChatController
that allows to insert/update messages so logic can be run outside the chat and reloads will not interrupt requests