client-api: Implement MSC2654: Unread counts
This commit is contained in:
parent
24bd27a3a9
commit
36aa0cb3cf
@ -18,6 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||
compat = []
|
||||
unstable-exhaustive-types = []
|
||||
unstable-msc2448 = []
|
||||
unstable-msc2654 = []
|
||||
unstable-msc3440 = []
|
||||
unstable-msc3488 = []
|
||||
client = []
|
||||
|
@ -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<UInt>,
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user