From fd8e8398ff6cd441474cf01478cd6395c2c8cc3d Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 12 Oct 2023 14:57:01 +0200 Subject: [PATCH] events: Add Thread::without_fallback There was no constructor that initializes the minimal set of required fields previously. --- crates/ruma-events/CHANGELOG.md | 5 +++++ crates/ruma-events/src/relation.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/crates/ruma-events/CHANGELOG.md b/crates/ruma-events/CHANGELOG.md index 37afee09..cfcccc40 100644 --- a/crates/ruma-events/CHANGELOG.md +++ b/crates/ruma-events/CHANGELOG.md @@ -1,5 +1,10 @@ # [unreleased] +Improvements: + +- Add `Thread::without_fallback` as a constructor that initializes the minimal + set of required fields + # 0.27.3 Improvements: diff --git a/crates/ruma-events/src/relation.rs b/crates/ruma-events/src/relation.rs index 4f736f71..c560cddb 100644 --- a/crates/ruma-events/src/relation.rs +++ b/crates/ruma-events/src/relation.rs @@ -113,6 +113,12 @@ impl Thread { Self { event_id, in_reply_to: Some(InReplyTo::new(latest_event_id)), is_falling_back: true } } + /// Convenience method to create a regular `Thread` relation with the given root event ID and + /// *without* the recommended reply fallback. + pub fn without_fallback(event_id: OwnedEventId) -> Self { + Self { event_id, in_reply_to: None, is_falling_back: false } + } + /// Convenience method to create a reply `Thread` relation with the given root event ID and /// replied-to event ID. pub fn reply(event_id: OwnedEventId, reply_to_event_id: OwnedEventId) -> Self {