Messages "from future" not appear in ChatActivity
When we open chat activity, it loads only messages older than current time, so it may cause wrong behaviour: if user has wrong time on a device, like two minutes later than current time, his message will not appear in ChatActivity on other device with correct time until the time of message come and ChatActivity reopened. However, if we subscribe for new messages, the event will come. In my case new messages counter notifies about new messages, but when I open ChatActivity, they not appear. ChatActivity receives only messages sent before current datetime and messages sent while ChatActivity open.
Steps to reproduce:
- two devices with different time: Device1 - correct time, Device2 - time later than correct
- Device2 send message1
- Device1 open ChatActivity - no message1.
- Device1 keeps staying in ChatActivity
- Device2 send message2
- Device1 receives message2 in ChatActivity, but still no message1.
I suggest to change AbstractThreadHandler.loadMoreMessagesForThread(), so if fromMesage == null, then load all messages, not from current date.
Thanks a lot anyway, the library is great!
OMG, thanks @Yariko-chan you solved the issue that me and developers could never replicate
I tried setting the time to the future but I can't replicate this issue. Even with the time set incorrectly, messages are still displayed correctly.
I've reviewed the code and the logic look like this:
- Are there some messages in the thread? If so listen to messages starting at the timestamp of the last message
- Is the thread deleted? If yes, listen to messages starting at the time of thread deletion.
- Otherwise listen to all messages.
Since all the timestamps are set by Firebase, there should never be a time when the device's current time interferes with the listeners. I even tested a case where I create a thread, close the app, set the time to an incorrect value, re-open the app and send a message. Messages still came through correctly.
To follow this up further, I would you to send me a demo project which is exhibiting this issue. I'm closing the issue for now, but if you still have this problem and can send me a demo project, I will reopen it.