-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sdk-base: add Room::pinned_events(&self)
#3747
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ use ruma::{ | |
join_rules::RoomJoinRulesEventContent, | ||
member::MembershipState, | ||
name::RoomNameEventContent, | ||
pinned_events::RoomPinnedEventsEventContent, | ||
tombstone::RoomTombstoneEventContent, | ||
topic::RoomTopicEventContent, | ||
}, | ||
|
@@ -117,6 +118,8 @@ pub struct BaseRoomInfo { | |
/// others, and this field collects them. | ||
#[serde(skip_serializing_if = "RoomNotableTags::is_empty", default)] | ||
pub(crate) notable_tags: RoomNotableTags, | ||
/// The `m.room.pinned_events` of this room. | ||
pub(crate) pinned_events: Option<RoomPinnedEventsEventContent>, | ||
} | ||
|
||
impl BaseRoomInfo { | ||
|
@@ -194,6 +197,9 @@ impl BaseRoomInfo { | |
ev.as_original().is_some_and(|o| !o.content.active_memberships(None).is_empty()) | ||
}); | ||
} | ||
AnySyncStateEvent::RoomPinnedEvents(p) => { | ||
self.pinned_events = p.as_original().map(|p| p.content.clone()); | ||
} | ||
_ => return false, | ||
} | ||
|
||
|
@@ -253,6 +259,11 @@ impl BaseRoomInfo { | |
// wont have call information. | ||
return false; | ||
} | ||
AnyStrippedStateEvent::RoomPinnedEvents(p) => { | ||
if let Some(pinned) = p.content.pinned.clone() { | ||
self.pinned_events = Some(RoomPinnedEventsEventContent::new(pinned)); | ||
} | ||
} | ||
Comment on lines
+262
to
+266
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not entirely sure about this part. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stripped events = for a room in which we're invited. I think your code is fine, we could also decide to store |
||
_ => return false, | ||
} | ||
|
||
|
@@ -349,6 +360,7 @@ impl Default for BaseRoomInfo { | |
rtc_member: BTreeMap::new(), | ||
is_marked_unread: false, | ||
notable_tags: RoomNotableTags::empty(), | ||
pinned_events: None, | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: i think we could have used
MinimalStateEvent
here, but it's unclear what's the value of it, so no need to change anything here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try changing it so it matches the other fields if it's easy to do (I'm not sure how I missed it 🫤 ).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it does make everything way more complex just to store a possible event id which isn't used anywhere, so it's probably not worth to add it.