Skip to content

Commit fc4cd53

Browse files
authored
event cache: introduce the Paginator API (#3309)
This introduces a new helper object to run arbitrary pagination requests, backwards- or forward-. At the moment they're disconnected from the event cache, although I've put the files there for future convenience, since at some point we'll want to merge the retrieved events with the cache (? maybe). This little state machine makes it possible to retrieve the initial data, given an initial event id, using the /context endpoint; then allow stateful pagination using a paginator kind of API. Paginating in the timeline indicates whether we've reached the start/end of the timeline. The test for the state subscription is quite extensive and makes sure the basic functionality works as intended. Some testing helpers have been (re)introduced in the SDK crate, simplifying the code, and introducing a better `EventFactory` / `EventBuilder` pattern than the existing one in the `matrix-sdk-test` crate. In particular, this can make use of some types in `matrix-sdk`, notably `SyncTimelineEvent` and `TimelineEvent`, and I've found the API to be simpler to use as well. Part of #3234.
1 parent 7c68096 commit fc4cd53

File tree

8 files changed

+901
-47
lines changed

8 files changed

+901
-47
lines changed

crates/matrix-sdk/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"]
1717

1818
[features]
1919
default = ["e2e-encryption", "automatic-room-key-forwarding", "sqlite", "native-tls"]
20-
testing = ["matrix-sdk-sqlite?/testing", "matrix-sdk-indexeddb?/testing", "matrix-sdk-base/testing", "wiremock"]
20+
testing = ["matrix-sdk-sqlite?/testing", "matrix-sdk-indexeddb?/testing", "matrix-sdk-base/testing", "wiremock", "matrix-sdk-test", "assert_matches2"]
2121

2222
e2e-encryption = [
2323
"matrix-sdk-base/e2e-encryption",
@@ -65,6 +65,7 @@ docsrs = ["e2e-encryption", "sqlite", "indexeddb", "sso-login", "qrcode", "image
6565
anyhow = { workspace = true, optional = true }
6666
anymap2 = "0.13.0"
6767
aquamarine = "0.5.0"
68+
assert_matches2 = { workspace = true, optional = true }
6869
as_variant = { workspace = true }
6970
async-channel = "2.1.0"
7071
async-stream = { workspace = true }
@@ -91,6 +92,7 @@ matrix-sdk-base = { workspace = true }
9192
matrix-sdk-common = { workspace = true }
9293
matrix-sdk-indexeddb = { workspace = true, optional = true }
9394
matrix-sdk-sqlite = { workspace = true, optional = true }
95+
matrix-sdk-test = { workspace = true, optional = true }
9496
mime = "0.3.16"
9597
mime2ext = "0.1.52"
9698
rand = { workspace = true , optional = true }

crates/matrix-sdk/src/event_cache/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ use self::{
7575
use crate::{client::ClientInner, room::MessagesOptions, Client, Room};
7676

7777
mod linked_chunk;
78+
pub mod paginator;
7879
mod store;
7980

8081
/// An error observed in the [`EventCache`].

0 commit comments

Comments
 (0)