Skip to content

Commit cdc3743

Browse files
committed
timeline: when aborting fails on a local echo, retry on the matching remote echo
1 parent 9b97a2e commit cdc3743

File tree

1 file changed

+26
-13
lines changed
  • crates/matrix-sdk-ui/src/timeline

1 file changed

+26
-13
lines changed

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

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ pub use self::{
100100
virtual_item::VirtualTimelineItem,
101101
};
102102
use self::{
103-
event_item::EventTimelineItemKind,
104103
futures::SendAttachment,
105104
inner::{ReactionAction, TimelineInner},
106105
reactions::ReactionToggleResult,
@@ -791,25 +790,39 @@ impl Timeline {
791790
event: &EventTimelineItem,
792791
reason: Option<&str>,
793792
) -> Result<bool, RedactEventError> {
794-
match &event.kind {
795-
EventTimelineItemKind::Local(local) => {
793+
let event_id = match event.identifier() {
794+
TimelineEventItemId::TransactionId(txn_id) => {
795+
let local = event.as_local().unwrap();
796+
796797
if let Some(handle) = local.send_handle.clone() {
797-
Ok(handle.abort().await.map_err(RedactEventError::RoomQueueError)?)
798+
if handle.abort().await.map_err(RedactEventError::RoomQueueError)? {
799+
return Ok(true);
800+
}
801+
802+
if let Some(event_id) = self.find_remote_by_transaction_id(&txn_id).await {
803+
event_id
804+
} else {
805+
warn!("Couldn't find the local echo anymore, nor a matching remote echo");
806+
return Ok(false);
807+
}
798808
} else {
799809
// No abort handle; theoretically unreachable for regular usage of the
800810
// timeline, but this may happen in testing contexts.
801-
Err(RedactEventError::UnsupportedRedactLocal(local.transaction_id.clone()))
811+
return Err(RedactEventError::UnsupportedRedactLocal(
812+
local.transaction_id.clone(),
813+
));
802814
}
803815
}
804816

805-
EventTimelineItemKind::Remote(remote) => {
806-
self.room()
807-
.redact(&remote.event_id, reason, None)
808-
.await
809-
.map_err(|err| RedactEventError::SdkError(err.into()))?;
810-
Ok(true)
811-
}
812-
}
817+
TimelineEventItemId::EventId(event_id) => event_id,
818+
};
819+
820+
self.room()
821+
.redact(&event_id, reason, None)
822+
.await
823+
.map_err(|err| RedactEventError::SdkError(err.into()))?;
824+
825+
Ok(true)
813826
}
814827

815828
/// Fetch unavailable details about the event with the given ID.

0 commit comments

Comments
 (0)