-
Notifications
You must be signed in to change notification settings - Fork 173
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
Double outgoing messages #30
Comments
So the way I handled this was actually having different logic for populating the message history (where you accept all messages) versus listening for new messages from the server (where you accept all messages that are not from the local user). The only other workaround I can think of is not having the library display the messages as the user sends them. The reason I chose not to do this when I created the library was so that if the user had a slow connection to the network, they wouldn't have a long delay between sending a message and viewing it. This seems to be how most other messaging applications handle it. Though I'm open to dissenting opinions. |
HI! I think I'm getting same problem as @atroutt . I have a Realm DB in the app. What I do is, recieve the message in a listener add it to db. Then when I open the chat. So the first I do is call a method (loadHistory) to show the last N messages.
} Since here, it works OK. BUT, the last message is duplicated. Then, when I write somthing , aumatically refresh the layout and the last message turns to the right one. P.S: Great job with the library ,) |
I worked around this the way you suggested @MatthewPageCS --I set up a one-time sync with the servers on creation of the chat screen and only after that completes I set up a listener that still receives all updates from the server, but does not pass along outgoing messages to the UI (since they are already displayed by the library). Example for Android with Firebase:
|
@hasaudrey But this causes double incoming messages. The |
I managed to find a temporary workaround to this. I created an ArrayList of messages and for each message I get from the server, I add it onto the ArrayList and I did That's the only workaround in case anybody else runs into this situation. Any other suggestions are welcome! |
I hooked up my SlyceMessaging UI to a Firebase backend and I'm seeing the issue when I send a message there are two showing up on the screen. It's because the library adds the first copy when the message is sent and then Firebase notifies me of the new message coming back from the server and I display that as well.
What is the recommended pattern for avoiding this?
I don't want to simply ignore messages from the local user coming from the server because then I won't be able to display the history correctly (messages I sent in previous sessions).
The text was updated successfully, but these errors were encountered: