Sometimes a recently sent message gets “split” in the UI with copies with different statuses? With a received in between.
Sometimes we see the same messages twice in the bottom page of a chat?
Sometimes I’ve sent a message and they reply from the other party ends up with a lower sort id than my send message. How is that even possible? Wasn’t even a MUC.
Found at least one bug: we set initial sortId to syncPoint on load, but what if we have send messages with no sync point after them? duplicate sort ids, strange results
I haven’t seen the old issues since the fixes, but I have a couple of times seen messages out of order at least on iOS, but then refreshing from DB got the right order so maybe that’s a different kind of issue.
One user reports seeing out of order messages routinely in the public MUC. They claim the messages all came in during on sync? Maybe overlapping syncs are causing strange issues if they happen?
Ok, I’ve identified at least one of the sorting issues (maybe there’s more, maybe not), and it has to do with edited messages. A mam sync can send us messages we already have. So when we get a duplicate message we delete the one in our database and store the new one, which means we will get the sortId that is assigned via the mam sync path.
However we only do this if the message doesn’t have versions. So if we know about a corrected message, we fall through to the correct message path, which preserves the sortId from the original message (which we want in a normal correction case).
So this can cause edited messages to show up in the wrong order after a sync.
Confirmed by running a manual sync in a channel and observing that edited messages did not have their sortIds changed but unedited ones did.