diff --git a/crates/ruma-client-api/Cargo.toml b/crates/ruma-client-api/Cargo.toml index bc122a56..c0ea3e82 100644 --- a/crates/ruma-client-api/Cargo.toml +++ b/crates/ruma-client-api/Cargo.toml @@ -18,6 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"] compat = [] unstable-exhaustive-types = [] unstable-msc2448 = [] +unstable-msc2654 = [] unstable-msc3440 = [] unstable-msc3488 = [] client = [] diff --git a/crates/ruma-client-api/src/sync/sync_events.rs b/crates/ruma-client-api/src/sync/sync_events.rs index e2706e2b..6d1ddcc8 100644 --- a/crates/ruma-client-api/src/sync/sync_events.rs +++ b/crates/ruma-client-api/src/sync/sync_events.rs @@ -267,6 +267,19 @@ pub mod v3 { /// room. #[serde(default, skip_serializing_if = "Ephemeral::is_empty")] pub ephemeral: Ephemeral, + + /// The number of unread events since the latest read receipt. + /// + /// This uses the unstable prefix in [MSC2654]. + /// + /// [MSC2654]: https://github.com/matrix-org/matrix-spec-proposals/pull/2654 + #[cfg(feature = "unstable-msc2654")] + #[serde( + rename = "org.matrix.msc2654.unread_count", + alias = "unread_count", + skip_serializing_if = "Option::is_none" + )] + pub unread_count: Option, } impl JoinedRoom { @@ -277,12 +290,18 @@ pub mod v3 { /// Returns true if there are no updates in the room. pub fn is_empty(&self) -> bool { - self.summary.is_empty() + let is_empty = self.summary.is_empty() && self.unread_notifications.is_empty() && self.timeline.is_empty() && self.state.is_empty() && self.account_data.is_empty() - && self.ephemeral.is_empty() + && self.ephemeral.is_empty(); + + #[cfg(not(feature = "unstable-msc2654"))] + return is_empty; + + #[cfg(feature = "unstable-msc2654")] + return is_empty && self.unread_count.is_none(); } } diff --git a/crates/ruma/Cargo.toml b/crates/ruma/Cargo.toml index 590c75f4..267fa665 100644 --- a/crates/ruma/Cargo.toml +++ b/crates/ruma/Cargo.toml @@ -119,6 +119,7 @@ unstable-msc2448 = [ "ruma-common/unstable-msc2448", "ruma-federation-api/unstable-msc2448" ] +unstable-msc2654 = ["ruma-client-api/unstable-msc2654"] unstable-msc2675 = ["ruma-common/unstable-msc2675"] unstable-msc2676 = ["ruma-common/unstable-msc2676"] unstable-msc2677 = ["ruma-common/unstable-msc2677"] @@ -145,6 +146,7 @@ __ci = [ "unstable-pre-spec", "unstable-msc1767", "unstable-msc2448", + "unstable-msc2654", "unstable-msc2675", "unstable-msc2676", "unstable-msc2677",