Skip to content

Commit 54fd40d

Browse files
committed
feat(sdk): Add new timeline API
1 parent 67d968d commit 54fd40d

File tree

14 files changed

+1573
-13
lines changed

14 files changed

+1573
-13
lines changed

Cargo.lock

Lines changed: 17 additions & 8 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: 5 additions & 1 deletion
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",
@@ -70,6 +72,7 @@ futures-core = "0.3.21"
7072
futures-signals = { version = "0.3.30", default-features = false }
7173
futures-util = { version = "0.3.21", default-features = false }
7274
http = "0.2.6"
75+
indexmap = "1.9.1"
7376
matrix-sdk-base = { version = "0.6.0", path = "../matrix-sdk-base", default_features = false }
7477
matrix-sdk-common = { version = "0.6.0", path = "../matrix-sdk-common" }
7578
matrix-sdk-indexeddb = { version = "0.2.0", path = "../matrix-sdk-indexeddb", default-features = false, optional = true }
@@ -107,7 +110,7 @@ features = [
107110
optional = true
108111

109112
[dependencies.ruma]
110-
version = "0.7.0"
113+
version = "0.7.4"
111114
features = ["client-api-c", "compat", "rand", "unstable-msc2448", "unstable-msc2965"]
112115

113116
[target.'cfg(target_arch = "wasm32")'.dependencies]
@@ -120,6 +123,7 @@ tokio = { version = "1.17.0", default-features = false, features = ["fs", "rt"]
120123

121124
[dev-dependencies]
122125
anyhow = "1.0.57"
126+
assert_matches = "1.5.0"
123127
dirs = "4.0.0"
124128
futures = { version = "0.3.21", default-features = false, features = ["executor"] }
125129
matches = "0.1.9"

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

Lines changed: 12 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,16 @@ impl Common {
251253
self.client.add_room_event_handler(self.room_id(), handler)
252254
}
253255

256+
/// Get a [`Timeline`] for this room.
257+
///
258+
/// This offers a higher-level API than event handlers, in treating things
259+
/// like edits and reactions as updates of existing items rather than new
260+
/// independent events.
261+
#[cfg(feature = "experimental-timeline")]
262+
pub fn timeline(&self) -> Timeline {
263+
Timeline::new(self)
264+
}
265+
254266
/// Fetch the event with the given `EventId` in this room.
255267
pub async fn event(&self, event_id: &EventId) -> Result<TimelineEvent> {
256268
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)