Skip to content

Commit 7cad237

Browse files
committed
refactor(event cache): reduce indent in maybe_apply_new_redaction
1 parent 72a3972 commit 7cad237

File tree

1 file changed

+28
-27
lines changed
  • crates/matrix-sdk/src/event_cache/room

1 file changed

+28
-27
lines changed

crates/matrix-sdk/src/event_cache/room/mod.rs

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,38 +1219,39 @@ mod private {
12191219
};
12201220

12211221
// Replace the redacted event by a redacted form, if we knew about it.
1222-
if let Some((location, mut target_event)) = self.find_event(event_id).await? {
1223-
// Don't redact already redacted events.
1224-
if let Ok(deserialized) = target_event.raw().deserialize() {
1225-
match deserialized {
1226-
AnySyncTimelineEvent::MessageLike(ev) => {
1227-
if ev.is_redacted() {
1228-
return Ok(());
1229-
}
1222+
let Some((location, mut target_event)) = self.find_event(event_id).await? else {
1223+
trace!("redacted event is missing from the linked chunk");
1224+
return Ok(());
1225+
};
1226+
1227+
// Don't redact already redacted events.
1228+
if let Ok(deserialized) = target_event.raw().deserialize() {
1229+
match deserialized {
1230+
AnySyncTimelineEvent::MessageLike(ev) => {
1231+
if ev.is_redacted() {
1232+
return Ok(());
12301233
}
1231-
AnySyncTimelineEvent::State(ev) => {
1232-
if ev.is_redacted() {
1233-
return Ok(());
1234-
}
1234+
}
1235+
AnySyncTimelineEvent::State(ev) => {
1236+
if ev.is_redacted() {
1237+
return Ok(());
12351238
}
12361239
}
12371240
}
1241+
}
12381242

1239-
if let Some(redacted_event) = apply_redaction(
1240-
target_event.raw(),
1241-
event.raw().cast_ref::<SyncRoomRedactionEvent>(),
1242-
&self.room_version,
1243-
) {
1244-
// It's safe to cast `redacted_event` here:
1245-
// - either the event was an `AnyTimelineEvent` cast to `AnySyncTimelineEvent`
1246-
// when calling .raw(), so it's still one under the hood.
1247-
// - or it wasn't, and it's a plain `AnySyncTimelineEvent` in this case.
1248-
target_event.replace_raw(redacted_event.cast());
1249-
1250-
self.replace_event_at(location, target_event).await?;
1251-
}
1252-
} else {
1253-
trace!("redacted event is missing from the linked chunk");
1243+
if let Some(redacted_event) = apply_redaction(
1244+
target_event.raw(),
1245+
event.raw().cast_ref::<SyncRoomRedactionEvent>(),
1246+
&self.room_version,
1247+
) {
1248+
// It's safe to cast `redacted_event` here:
1249+
// - either the event was an `AnyTimelineEvent` cast to `AnySyncTimelineEvent`
1250+
// when calling .raw(), so it's still one under the hood.
1251+
// - or it wasn't, and it's a plain `AnySyncTimelineEvent` in this case.
1252+
target_event.replace_raw(redacted_event.cast());
1253+
1254+
self.replace_event_at(location, target_event).await?;
12541255
}
12551256

12561257
Ok(())

0 commit comments

Comments
 (0)