robrix icon indicating copy to clipboard operation
robrix copied to clipboard

Save and restore event cache to/from persistent storage

Open kevinaboos opened this issue 1 year ago • 2 comments

Now that a user's login session is properly persisted to/from storage on all platforms, the next step is to:

  1. Serialize the actual set of all timeline events (as a list of SyncTimelineEvents) upon app exit, or perhaps upon another lifecycle stage.
  2. Deserialize them and repopulate the event cache before synchronizing any timelines, using the EventCache::add_initial_events()
    • We just removed an erroneous invocation of this function in fde5d29711363f49fdc3503125a90522bffac677

kevinaboos avatar Sep 26 '24 20:09 kevinaboos

This is blocked on the Matrix Rust SDK, which currently doesn't fully implement EventCache features that allow the client to customize how events are extracted from and imported into the cache.

kevinaboos avatar Nov 11 '24 23:11 kevinaboos

Hmm, actually it appears that the SDK might support this, at least in part, by using the ClientBuilder to configure a client to use an existing state store and cache path.

https://matrix-org.github.io/matrix-rust-sdk/matrix_sdk/struct.ClientBuilder.html#method.sqlite_store_with_cache_path

However, that being said, I haven't tried it yet and am not sure if pointing a Client at an existing database & cache in the filesystem will actually cause the SDK to pull in those old events into the Client's EventCache or have them initially populate the rooms & timelines.

kevinaboos avatar Jan 15 '25 00:01 kevinaboos