Skip to content

Commit

Permalink
feat(base): Implement Room::direct_targets_length.
Browse files Browse the repository at this point in the history
This patch implements `Room::direct_targets_length`. It avoids to call
`Room::is_direct` if and only if we don't care about the room's state
and we don't want an async call, and if we don't want to pay the cost of
`Room::direct_targets` which clones the `HashSet` as an alternative way
to get a similar information than `Room::is_direct`.
  • Loading branch information
Hywan committed Feb 7, 2024
1 parent 2c688fd commit f950e67
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/matrix-sdk-base/src/rooms/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,12 @@ impl Room {
self.inner.read().base_info.dm_targets.clone()
}

/// If this room is a direct message, returns the number of members that
/// we're sharing the room with.
pub fn direct_targets_length(&self) -> usize {
self.inner.read().base_info.dm_targets.len()
}

/// Is the room encrypted.
pub fn is_encrypted(&self) -> bool {
self.inner.read().is_encrypted()
Expand Down

0 comments on commit f950e67

Please sign in to comment.