-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PreviewDataFetched on every old message when a new message comes in #64
Comments
Hi, thanks for asking. Flutter fully reloads visible messages when update happens, we can't do anything about it. Regarding the preview, as you can see in the example here https://github.com/flyerhq/flutter_chat_ui/blob/main/example/lib/main.dart#L148 or inside the Firebase lib https://github.com/flyerhq/flutter_firebase_chat_core/blob/main/example/lib/chat.dart#L167 you need to implement |
Don't you think instead of making message.dart a StatelessWidget we can have a StatefulWidget which might solve this issue. Didn't tried just an OPINION, i don't know if it will work or not but we can try this. Or if performance is not concerned we can even add AutomaticKeepAliveClientMixin to message.dart so that it will not loose its state while refreshing or building state again on new messages add or list change. Again it's just an OPINION didn't tried. |
@zahidshaikh08 my comment above should solve the issue, it is how we planned it work, it is how it works with Firebase. We had stateful widget before and it didn't work, don't remember the problem exactly, but it was so bad we replaced it with stateless widget and came up with this callback/user stores data system. Not an option to keep these in memory since this chat should work on thousands of messages. |
@demchenkoalex haha I completely missed it! I didn't realize the strategy was to update firestore with the preview, I thought it was expected to do it on the fly (locally) each time. That clears it up for sure, makes sense. |
Hey guys, finally got around to playing with flyer today. It's really simple and easy to use, nice! I pretty much was just following the example except sending/receiving messages from back end.
If let's say a link was sent, It shows the link briefly and then shows the preview data when it becomes available - which is nice, this is great.
But then when a new message comes in and "messages" updates. it adds the new message to the bottom and that previous message switches back to a link and then shows the preview data again. So, it's like starting over processing every message every time a new message comes in which is kind of jarring as it jumps back and forth between a link and the preview data every time a message comes in.
I'm not sure if theres something I can do in my implementation to make messages incremental instead of a full reload? Or if this is something that needs to happen inside the library to do a diff? Let me know if I'm doing something wrong.
The text was updated successfully, but these errors were encountered: