Skip to content

Commit c530757

Browse files
committed
feat(ui,ffi): Add LatestEventValue::Local { profile, .. }.
This patch adds a `profile: TimelineDetails<Profile>` field to `LatestEventValue::Local` in `matrix_sdk_ui::timeline` (and the corresponding `matrix_sdk_ffi` type).
1 parent 75a977c commit c530757

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

bindings/matrix-sdk-ffi/src/timeline/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,7 @@ pub enum LatestEventValue {
13041304
},
13051305
Local {
13061306
timestamp: Timestamp,
1307+
profile: ProfileDetails,
13071308
content: TimelineItemContent,
13081309
is_sending: bool,
13091310
},
@@ -1322,9 +1323,12 @@ impl From<UiLatestEventValue> for LatestEventValue {
13221323
content: content.into(),
13231324
}
13241325
}
1325-
UiLatestEventValue::Local { timestamp, content, is_sending } => {
1326-
Self::Local { timestamp: timestamp.into(), content: content.into(), is_sending }
1327-
}
1326+
UiLatestEventValue::Local { timestamp, profile, content, is_sending } => Self::Local {
1327+
timestamp: timestamp.into(),
1328+
profile: profile.into(),
1329+
content: content.into(),
1330+
is_sending,
1331+
},
13281332
}
13291333
}
13301334
}

crates/matrix-sdk-ui/src/timeline/latest_event.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ pub enum LatestEventValue {
5454
/// The timestamp of the local event.
5555
timestamp: MilliSecondsSinceUnixEpoch,
5656

57+
/// The sender's profile.
58+
profile: TimelineDetails<Profile>,
59+
5760
/// The content of the local event.
5861
content: TimelineItemContent,
5962

@@ -114,11 +117,17 @@ impl LatestEventValue {
114117
return Self::None;
115118
};
116119

120+
let sender = client.user_id().expect("The `Client` is supposed to be logged");
121+
let profile = room
122+
.profile_from_user_id(sender)
123+
.await
124+
.map(TimelineDetails::Ready)
125+
.unwrap_or(TimelineDetails::Unavailable);
117126
let is_sending = matches!(value, BaseLatestEventValue::LocalIsSending(_));
118127

119128
match TimelineAction::from_content(message_like_event_content, None, None, None) {
120129
TimelineAction::AddItem { content } => {
121-
Self::Local { timestamp, content, is_sending }
130+
Self::Local { timestamp, profile, content, is_sending }
122131
}
123132

124133
TimelineAction::HandleAggregation { kind, .. } => {
@@ -226,8 +235,9 @@ mod tests {
226235
let value =
227236
LatestEventValue::from_base_latest_event_value(base_value, &room, &client).await;
228237

229-
assert_matches!(value, LatestEventValue::Local { timestamp, content, is_sending } => {
238+
assert_matches!(value, LatestEventValue::Local { timestamp, profile, content, is_sending } => {
230239
assert_eq!(u64::from(timestamp.get()), 42u64);
240+
assert_matches!(profile, TimelineDetails::Unavailable);
231241
assert_matches!(
232242
content,
233243
TimelineItemContent::MsgLike(MsgLikeContent { kind: MsgLikeKind::Message(_), .. })
@@ -255,8 +265,9 @@ mod tests {
255265
let value =
256266
LatestEventValue::from_base_latest_event_value(base_value, &room, &client).await;
257267

258-
assert_matches!(value, LatestEventValue::Local { timestamp, content, is_sending } => {
268+
assert_matches!(value, LatestEventValue::Local { timestamp, profile, content, is_sending } => {
259269
assert_eq!(u64::from(timestamp.get()), 42u64);
270+
assert_matches!(profile, TimelineDetails::Unavailable);
260271
assert_matches!(
261272
content,
262273
TimelineItemContent::MsgLike(MsgLikeContent { kind: MsgLikeKind::Message(_), .. })

0 commit comments

Comments
 (0)