prose-core-client icon indicating copy to clipboard operation
prose-core-client copied to clipboard

Implement reliable message caching

Open nesium opened this issue 10 months ago • 0 comments

The goal is to minimize roundtrips to the server for messages that have been loaded already.

Some loose thoughts:

I believe that going back in the local message list and see which ones have an ArchiveID does not work reliably. There is no way to know which messages you may have missed. Even using Stream Management (XEP-0198) you only know earlier that you’re missing messages, well even how many in fact. But there’s also the scenario where the user could quit the app at any time when fetching missing messages (or a blackout). So that feature is basically only for reliably sending messages. You can cache sent messages in a local db until you receive a confirmation from the server that they have been received. Additionally the user could open the app hours/days/weeks later and loading the latest batch of messages could leave a hole between the latest and the last received ones. So you’d have unreliable data in the past locally.

My take is that the only guarantee is receiving a page from the server (MAM) with a count. You’d then know that at least between two message IDs you’d have all the messages in between. Thus the cache would need to be modelled around this concept (messages belonging to a page). Of course there would be some redundant loading until a page is full.

Relates to #21

nesium avatar Aug 18 '23 12:08 nesium