Skip to content

Commit 8d8846a

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 9d63af6 commit 8d8846a

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};
@@ -418,7 +416,7 @@ impl RoomPagination {
418416
debug!("not storing previous batch token, because we deduplicated all new back-paginated events");
419417
}
420418

421-
EventsPostProcessing::HaveBeenInserted(reversed_events)
419+
reversed_events
422420
})
423421
.await?;
424422

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

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

568568
room_events.push_events(events.clone());
569569

570-
EventsPostProcessing::HaveBeenInserted(events.clone())
570+
events.clone()
571571
})
572572
.await?;
573573

@@ -689,8 +689,7 @@ mod private {
689689
EventCacheError,
690690
},
691691
events::RoomEvents,
692-
sort_positions_descending, EventLocation, EventsPostProcessing,
693-
LoadMoreEventsBackwardsOutcome,
692+
sort_positions_descending, EventLocation, LoadMoreEventsBackwardsOutcome,
694693
};
695694
use crate::event_cache::RoomPaginationStatus;
696695

@@ -1121,7 +1120,7 @@ mod private {
11211120
)
11221121
.expect("failed to remove an event");
11231122

1124-
EventsPostProcessing::None
1123+
vec![]
11251124
})
11261125
.await?;
11271126

@@ -1256,27 +1255,26 @@ mod private {
12561255
///
12571256
/// Returns the updates to the linked chunk, as vector diffs, so the
12581257
/// caller may propagate such updates, if needs be.
1258+
///
1259+
/// The function `func` takes a mutable reference to `RoomEvents`. It
1260+
/// returns a set of events that will be post-processed. At the time of
1261+
/// writing, all these events are passed to
1262+
/// `Self::maybe_apply_new_redaction`.
12591263
#[must_use = "Updates as `VectorDiff` must probably be propagated via `RoomEventCacheUpdate`"]
12601264
pub async fn with_events_mut<F>(
12611265
&mut self,
12621266
func: F,
12631267
) -> Result<Vec<VectorDiff<TimelineEvent>>, EventCacheError>
12641268
where
1265-
F: FnOnce(&mut RoomEvents) -> EventsPostProcessing,
1269+
F: FnOnce(&mut RoomEvents) -> Vec<TimelineEvent>,
12661270
{
1267-
let post_processing = func(&mut self.events);
1271+
let events_to_post_process = func(&mut self.events);
12681272

12691273
// Update the store before doing the post-processing.
12701274
self.propagate_changes().await?;
12711275

1272-
match post_processing {
1273-
EventsPostProcessing::HaveBeenInserted(events) => {
1274-
for event in &events {
1275-
self.maybe_apply_new_redaction(event).await?;
1276-
}
1277-
}
1278-
1279-
EventsPostProcessing::None => {}
1276+
for event in &events_to_post_process {
1277+
self.maybe_apply_new_redaction(event).await?;
12801278
}
12811279

12821280
// If we've never waited for an initial previous-batch token, and we now have at
@@ -1383,15 +1381,6 @@ mod private {
13831381
}
13841382
}
13851383

1386-
/// Output of the callback passed to `RoomEventCacheState::with_events_mut`.
1387-
pub(super) enum EventsPostProcessing {
1388-
/// Trigger the post-processing when new events have been inserted.
1389-
HaveBeenInserted(Vec<TimelineEvent>),
1390-
1391-
/// No post-processing.
1392-
None,
1393-
}
1394-
13951384
/// An enum representing where an event has been found.
13961385
pub(super) enum EventLocation {
13971386
/// Event lives in memory (and likely in the store!).

0 commit comments

Comments
 (0)