mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-05 14:35:20 -04:00
refactor(timeline): use load_or_fetch_event when fetching a reply's content
This commit is contained in:
@@ -1529,9 +1529,7 @@ async fn fetch_replied_to_event(
|
||||
drop(state);
|
||||
|
||||
trace!("Fetching replied-to event");
|
||||
|
||||
// TODO: read from the event cache, if available, or fetch from the server.
|
||||
let res = match room.event(in_reply_to, None).await {
|
||||
let res = match room.load_or_fetch_event(in_reply_to, None).await {
|
||||
Ok(timeline_event) => TimelineDetails::Ready(Box::new(
|
||||
RepliedToEvent::try_from_timeline_event(timeline_event, room).await?,
|
||||
)),
|
||||
|
||||
@@ -457,8 +457,7 @@ impl Timeline {
|
||||
return timeline_item.replied_to_info();
|
||||
}
|
||||
|
||||
// TODO: read from the event cache, if available, or fetch from the server.
|
||||
let event = self.room().event(event_id, None).await.map_err(|error| {
|
||||
let event = self.room().load_or_fetch_event(event_id, None).await.map_err(|error| {
|
||||
error!("Failed to fetch event with ID {event_id} with error: {error}");
|
||||
UnsupportedReplyItem::MissingEvent
|
||||
})?;
|
||||
|
||||
@@ -868,11 +868,6 @@ async fn test_send_reply_with_event_id() {
|
||||
.mount()
|
||||
.await;
|
||||
|
||||
// Since we assume we can't use the timeline item directly in this use case, the
|
||||
// API will fetch the event from the server directly so we need to mock the
|
||||
// response.
|
||||
server.mock_room_event().ok(bob_event).named("event_1").mock_once().mount().await;
|
||||
|
||||
let replied_to_info = timeline.replied_to_info_from_event_id(event_id_from_bob).await.unwrap();
|
||||
timeline
|
||||
.send_reply(
|
||||
@@ -1148,11 +1143,6 @@ async fn test_send_reply_with_event_id_that_is_redacted() {
|
||||
.mount()
|
||||
.await;
|
||||
|
||||
// Since we assume we can't use the timeline item directly in this use case, the
|
||||
// API will fetch the event from the server directly so we need to mock the
|
||||
// response.
|
||||
server.mock_room_event().ok(event_from_bob).mock_once().named("event_1").mount().await;
|
||||
|
||||
let replied_to_info =
|
||||
timeline.replied_to_info_from_event_id(redacted_event_id_from_bob).await.unwrap();
|
||||
timeline
|
||||
|
||||
Reference in New Issue
Block a user