Skip to content

Commit 681b221

Browse files
committed
refactor(timeline): add more logs when we couldn't create an embedded event
This should help figuring out why some thread's latest replies are marked as "unsupported events".
1 parent 248d77a commit 681b221

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

crates/matrix-sdk-ui/src/timeline/controller/state_transaction.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ impl<'a, P: RoomDataProvider> TimelineStateTransaction<'a, P> {
558558

559559
// Attempt to load a thread's latest reply as an embedded timeline item, either
560560
// using the event cache or the storage.
561+
#[instrument(skip(self, room_data_provider))]
561562
async fn fetch_latest_thread_reply(
562563
&mut self,
563564
event_id: &EventId,

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ impl TimelineAction {
194194

195195
/// Create a new [`TimelineAction`] from a given remote event.
196196
///
197-
/// The return value may be `None` if handling the event (be it a new item
198-
/// or an aggregation) is not supported for this event type.
197+
/// The return value may be `None` if the event was a redacted reaction.
199198
#[allow(clippy::too_many_arguments)]
200199
pub async fn from_event<P: RoomDataProvider>(
201200
event: AnySyncTimelineEvent,

crates/matrix-sdk-ui/src/timeline/event_item/content/reply.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,24 @@ impl EmbeddedEvent {
133133
)
134134
.await;
135135

136-
let Some(TimelineAction::AddItem { content }) = action else {
137-
// The event can't be represented as a standalone timeline item.
138-
return Ok(None);
139-
};
136+
match action {
137+
Some(TimelineAction::AddItem { content }) => {
138+
let sender_profile = TimelineDetails::from_initial_value(
139+
room_data_provider.profile_from_user_id(&sender).await,
140+
);
141+
Ok(Some(Self { content, sender, sender_profile, timestamp, identifier }))
142+
}
140143

141-
let sender_profile = TimelineDetails::from_initial_value(
142-
room_data_provider.profile_from_user_id(&sender).await,
143-
);
144+
Some(TimelineAction::HandleAggregation { kind, .. }) => {
145+
// The event can't be represented as a standalone timeline item.
146+
warn!("embedded event is an aggregation: {}", kind.debug_string());
147+
Ok(None)
148+
}
144149

145-
Ok(Some(Self { content, sender, sender_profile, timestamp, identifier }))
150+
None => {
151+
warn!("embedded event lead to no action (neither an aggregation nor a new item)");
152+
Ok(None)
153+
}
154+
}
146155
}
147156
}

0 commit comments

Comments
 (0)