events: Add Thread::without_fallback

There was no constructor that initializes the minimal set of required
fields previously.
This commit is contained in:
Jonas Platte 2023-10-12 14:57:01 +02:00
parent 2708baeed8
commit fd8e8398ff
No known key found for this signature in database
GPG Key ID: AAA7A61F696C3E0C
2 changed files with 11 additions and 0 deletions

View File

@ -1,5 +1,10 @@
# [unreleased] # [unreleased]
Improvements:
- Add `Thread::without_fallback` as a constructor that initializes the minimal
set of required fields
# 0.27.3 # 0.27.3
Improvements: Improvements:

View File

@ -113,6 +113,12 @@ impl Thread {
Self { event_id, in_reply_to: Some(InReplyTo::new(latest_event_id)), is_falling_back: true } 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 /// Convenience method to create a reply `Thread` relation with the given root event ID and
/// replied-to event ID. /// replied-to event ID.
pub fn reply(event_id: OwnedEventId, reply_to_event_id: OwnedEventId) -> Self { pub fn reply(event_id: OwnedEventId, reply_to_event_id: OwnedEventId) -> Self {