Skip to content

Commit

Permalink
chore(ffi): revert to using a room method to edit if a remote event c…
Browse files Browse the repository at this point in the history
…ouldn't be found in the timeline

This maintains functionality we had prior to the previous commit: if an
event's missing from the timeline (e.g. timeline's been cleared after a
gappy sync response), then still allow editing it.
  • Loading branch information
bnjbvr committed Oct 16, 2024
1 parent 16c2b82 commit 0490df2
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions bindings/matrix-sdk-ffi/src/timeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,28 @@ impl Timeline {
&self,
event_or_transaction_id: EventOrTransactionId,
new_content: EditedContent,
) -> Result<bool, ClientError> {
self.inner
.edit(&event_or_transaction_id.try_into()?, new_content.try_into()?)
.await
.map_err(Into::into)
) -> Result<(), ClientError> {
let edited = self
.inner
.edit(&event_or_transaction_id.clone().try_into()?, new_content.clone().try_into()?)
.await?;

if !edited {
// If we couldn't edit, assume it was an (remote) event that wasn't in the
// timeline, and try to edit it via the room itself.
let event_id = match event_or_transaction_id {
EventOrTransactionId::EventId { event_id } => EventId::parse(event_id)?,
EventOrTransactionId::TransactionId { .. } => {
warn!("trying to apply an edit to a local echo that doesn't exist in this timeline, aborting");
return Ok(());
}
};
let room = self.inner.room();
let edit_event = room.make_edit_event(&event_id, new_content.try_into()?).await?;
room.send_queue().send(edit_event).await?;
}

Ok(())
}

pub async fn send_location(
Expand Down

0 comments on commit 0490df2

Please sign in to comment.