Skip to content

Commit 9dc7a37

Browse files
committed
chore(sdk): Remove EventsPostProcessing.
This patch removes the `EventsPostProcessing` type, it assumes `with_events_muts` will always return events that will be post-process. The case where `EventsPostProcessing::None` becomes a `vec![]`.
1 parent 1d46770 commit 9dc7a37

File tree

2 files changed

+14
-27
lines changed

2 files changed

+14
-27
lines changed

crates/matrix-sdk/src/event_cache/pagination.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ use tracing::{debug, instrument, trace};
2727

2828
use super::{
2929
deduplicator::DeduplicationOutcome,
30-
room::{
31-
events::Gap, EventsPostProcessing, LoadMoreEventsBackwardsOutcome, RoomEventCacheInner,
32-
},
30+
room::{events::Gap, LoadMoreEventsBackwardsOutcome, RoomEventCacheInner},
3331
BackPaginationOutcome, EventsOrigin, Result, RoomEventCacheState, RoomEventCacheUpdate,
3432
};
3533
use crate::{event_cache::EventCacheError, room::MessagesOptions};
@@ -419,7 +417,7 @@ impl RoomPagination {
419417
debug!("not storing previous batch token, because we deduplicated all new back-paginated events");
420418
}
421419

422-
EventsPostProcessing::HaveBeenInserted(reversed_events)
420+
reversed_events
423421
})
424422
.await?;
425423

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

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ impl RoomEventCacheInner {
554554

555555
room_events.push_events(events.clone());
556556

557-
EventsPostProcessing::HaveBeenInserted(events.clone())
557+
events.clone()
558558
})
559559
.await?;
560560

@@ -676,8 +676,7 @@ mod private {
676676
EventCacheError,
677677
},
678678
events::RoomEvents,
679-
sort_positions_descending, EventLocation, EventsPostProcessing,
680-
LoadMoreEventsBackwardsOutcome,
679+
sort_positions_descending, EventLocation, LoadMoreEventsBackwardsOutcome,
681680
};
682681
use crate::event_cache::RoomPaginationStatus;
683682

@@ -1102,7 +1101,7 @@ mod private {
11021101
)
11031102
.expect("failed to remove an event");
11041103

1105-
EventsPostProcessing::None
1104+
vec![]
11061105
})
11071106
.await?;
11081107

@@ -1226,27 +1225,26 @@ mod private {
12261225
///
12271226
/// Returns the updates to the linked chunk, as vector diffs, so the
12281227
/// caller may propagate such updates, if needs be.
1228+
///
1229+
/// The function `func` takes a mutable reference to `RoomEvents`. It
1230+
/// returns a set of events that will be post-processed. At the time of
1231+
/// writing, all these events are passed to
1232+
/// `Self::maybe_apply_new_redaction`.
12291233
#[must_use = "Updates as `VectorDiff` must probably be propagated via `RoomEventCacheUpdate`"]
12301234
pub async fn with_events_mut<F>(
12311235
&mut self,
12321236
func: F,
12331237
) -> Result<Vec<VectorDiff<TimelineEvent>>, EventCacheError>
12341238
where
1235-
F: FnOnce(&mut RoomEvents) -> EventsPostProcessing,
1239+
F: FnOnce(&mut RoomEvents) -> Vec<TimelineEvent>,
12361240
{
1237-
let post_processing = func(&mut self.events);
1241+
let events_to_post_process = func(&mut self.events);
12381242

12391243
// Update the store before doing the post-processing.
12401244
self.propagate_changes().await?;
12411245

1242-
match post_processing {
1243-
EventsPostProcessing::HaveBeenInserted(events) => {
1244-
for event in &events {
1245-
self.maybe_apply_new_redaction(event).await?;
1246-
}
1247-
}
1248-
1249-
EventsPostProcessing::None => {}
1246+
for event in &events_to_post_process {
1247+
self.maybe_apply_new_redaction(event).await?;
12501248
}
12511249

12521250
// If we've never waited for an initial previous-batch token, and we now have at
@@ -1353,15 +1351,6 @@ mod private {
13531351
}
13541352
}
13551353

1356-
/// Output of the callback passed to `RoomEventCacheState::with_events_mut`.
1357-
pub(super) enum EventsPostProcessing {
1358-
/// Trigger the post-processing when new events have been inserted.
1359-
HaveBeenInserted(Vec<TimelineEvent>),
1360-
1361-
/// No post-processing.
1362-
None,
1363-
}
1364-
13651354
/// An enum representing where an event has been found.
13661355
pub(super) enum EventLocation {
13671356
/// Event lives in memory (and likely in the store!).

0 commit comments

Comments
 (0)