Skip to content

Commit b76484d

Browse files
committed
feat(sdk): Add new timeline API
1 parent ab1a6a6 commit b76484d

File tree

14 files changed

+1454
-4
lines changed

14 files changed

+1454
-4
lines changed

Cargo.lock

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindings/matrix-sdk-ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ futures-signals = { version = "0.3.28" }
2323
futures-util = { version = "0.3.17", default-features = false }
2424
# FIXME: we currently can't feature flag anything in the api.udl, therefore we must enforce sliding-sync being exposed here..
2525
# see https://github.com/matrix-org/matrix-rust-sdk/issues/1014
26-
matrix-sdk = { path = "../../crates/matrix-sdk", features = ["anyhow", "markdown", "sliding-sync", "socks"], version = "0.6.0" }
26+
matrix-sdk = { path = "../../crates/matrix-sdk", features = ["anyhow", "experimental-timeline", "markdown", "sliding-sync", "socks"], version = "0.6.0" }
2727
once_cell = "1.10.0"
2828
sanitize-filename-reader-friendly = "2.2.1"
2929
serde = { version = "1", features = ["derive"] }

crates/matrix-sdk/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ appservice = ["ruma/appservice-api-s"]
4242
image-proc = ["dep:image"]
4343
image-rayon = ["image-proc", "image?/jpeg_rayon"]
4444

45+
experimental-timeline = []
46+
4547
sliding-sync = [
4648
"matrix-sdk-base/sliding-sync",
4749
"anyhow",
@@ -68,6 +70,7 @@ futures-core = "0.3.21"
6870
futures-signals = { version = "0.3.30", default-features = false }
6971
futures-util = { version = "0.3.21", default-features = false }
7072
http = "0.2.6"
73+
indexmap = "1.9.1"
7174
matrix-sdk-common = { version = "0.6.0", path = "../matrix-sdk-common" }
7275
matrix-sdk-indexeddb = { version = "0.2.0", path = "../matrix-sdk-indexeddb", default-features = false, optional = true }
7376
matrix-sdk-sled = { version = "0.2.0", path = "../matrix-sdk-sled", default-features = false, optional = true }
@@ -137,6 +140,7 @@ tokio = { version = "1.17.0", default-features = false, features = ["fs", "rt"]
137140

138141
[dev-dependencies]
139142
anyhow = "1.0.57"
143+
assert_matches = "1.5.0"
140144
dirs = "4.0.0"
141145
futures = { version = "0.3.21", default-features = false, features = ["executor"] }
142146
matches = "0.1.9"

crates/matrix-sdk/src/room/common.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ use ruma::{
3737
};
3838
use serde::de::DeserializeOwned;
3939

40+
#[cfg(feature = "experimental-timeline")]
41+
use super::timeline::Timeline;
4042
use crate::{
4143
event_handler::{EventHandler, EventHandlerHandle, EventHandlerResult, SyncEvent},
4244
media::{MediaFormat, MediaRequest},
@@ -251,6 +253,12 @@ impl Common {
251253
self.client.add_room_event_handler(self.room_id(), handler)
252254
}
253255

256+
#[allow(missing_docs)] // FIXME(jplatte)
257+
#[cfg(feature = "experimental-timeline")]
258+
pub fn timeline(&self) -> Timeline {
259+
Timeline::new(self)
260+
}
261+
254262
/// Fetch the event with the given `EventId` in this room.
255263
pub async fn event(&self, event_id: &EventId) -> Result<TimelineEvent> {
256264
let request = get_room_event::v3::Request::new(self.room_id(), event_id);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ mod invited;
99
mod joined;
1010
mod left;
1111
mod member;
12+
#[cfg(feature = "experimental-timeline")]
13+
pub mod timeline;
1214

1315
pub use self::{
1416
common::{Common, Messages, MessagesOptions},

0 commit comments

Comments
 (0)