Skip to content

Commit 6762e70

Browse files
committed
chore(sdk): Rename variants of RoomEventCacheGenericUpdate.
This patch renames variants of `RoomEventCacheGenericUpdate`: - `TimelineUpdated` becomes `UpdateTimeline`, - `Cleared` becomes `Clear`. It matches the rest of the codebase where we use _verb_ + _subject_.
1 parent 6b93f66 commit 6762e70

File tree

4 files changed

+24
-26
lines changed

4 files changed

+24
-26
lines changed

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl EventCache {
379379
/// If one wants to get a high-overview, generic, updates for rooms, and
380380
/// without side-effects, this method is recommended. For example, it
381381
/// doesn't provide a list of new events, but rather a
382-
/// [`RoomEventCacheGenericUpdate::TimelineUpdated`] update. Also, dropping
382+
/// [`RoomEventCacheGenericUpdate::UpdateTimeline`] update. Also, dropping
383383
/// the receiver of this channel will not trigger any side-effect.
384384
pub fn subscribe_to_room_generic_updates(&self) -> Receiver<RoomEventCacheGenericUpdate> {
385385
self.inner.room_event_cache_generic_update_sender.subscribe()
@@ -497,7 +497,7 @@ impl EventCacheInner {
497497
let _ = room
498498
.inner
499499
.generic_update_sender
500-
.send(RoomEventCacheGenericUpdate::Cleared { room_id: room.inner.room_id.clone() });
500+
.send(RoomEventCacheGenericUpdate::Clear { room_id: room.inner.room_id.clone() });
501501

502502
Ok::<_, EventCacheError>(())
503503
}))
@@ -604,9 +604,7 @@ impl EventCacheInner {
604604
// emit a generic update.
605605
if timeline_is_not_empty {
606606
let _ = self.room_event_cache_generic_update_sender.send(
607-
RoomEventCacheGenericUpdate::TimelineUpdated {
608-
room_id: room_id.to_owned(),
609-
},
607+
RoomEventCacheGenericUpdate::UpdateTimeline { room_id: room_id.to_owned() },
610608
);
611609
}
612610

@@ -640,13 +638,13 @@ pub struct BackPaginationOutcome {
640638
pub enum RoomEventCacheGenericUpdate {
641639
/// The timeline has been updated, i.e. an event has been added, redacted,
642640
/// removed, or reloaded.
643-
TimelineUpdated {
641+
UpdateTimeline {
644642
/// The room ID owning the timeline.
645643
room_id: OwnedRoomId,
646644
},
647645

648646
/// The room has been cleared, all events have been deleted.
649-
Cleared {
647+
Clear {
650648
/// The ID of the room that has been cleared.
651649
room_id: OwnedRoomId,
652650
},
@@ -656,8 +654,8 @@ impl RoomEventCacheGenericUpdate {
656654
/// Get the room ID that has triggered this generic update.
657655
pub fn room_id(&self) -> &RoomId {
658656
match self {
659-
Self::TimelineUpdated { room_id } => room_id,
660-
Self::Cleared { room_id } => room_id,
657+
Self::UpdateTimeline { room_id } => room_id,
658+
Self::Clear { room_id } => room_id,
661659
}
662660
}
663661
}
@@ -925,7 +923,7 @@ mod tests {
925923

926924
assert_matches!(
927925
generic_stream.recv().await,
928-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id }) => {
926+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id }) => {
929927
assert_eq!(room_id, room_id_0);
930928
}
931929
);
@@ -1013,7 +1011,7 @@ mod tests {
10131011

10141012
assert_matches!(
10151013
generic_stream.recv().await,
1016-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: expected_room_id }) => {
1014+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: expected_room_id }) => {
10171015
assert_eq!(room_id, expected_room_id);
10181016
}
10191017
);
@@ -1027,7 +1025,7 @@ mod tests {
10271025
assert!(pagination_outcome.reached_start.not());
10281026
assert_matches!(
10291027
generic_stream.recv().await,
1030-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: expected_room_id }) => {
1028+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: expected_room_id }) => {
10311029
assert_eq!(room_id, expected_room_id);
10321030
}
10331031
);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl RoomPagination {
157157
// Send a room event cache generic update.
158158
if !outcome.events.is_empty() {
159159
let _ = self.inner.generic_update_sender.send(
160-
RoomEventCacheGenericUpdate::TimelineUpdated {
160+
RoomEventCacheGenericUpdate::UpdateTimeline {
161161
room_id: self.inner.room_id.clone(),
162162
},
163163
);

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl RoomEventCache {
387387
let _ = self
388388
.inner
389389
.generic_update_sender
390-
.send(RoomEventCacheGenericUpdate::Cleared { room_id: self.inner.room_id.clone() });
390+
.send(RoomEventCacheGenericUpdate::Clear { room_id: self.inner.room_id.clone() });
391391

392392
Ok(())
393393
}
@@ -576,7 +576,7 @@ impl RoomEventCacheInner {
576576
}
577577

578578
if update_has_been_sent {
579-
let _ = self.generic_update_sender.send(RoomEventCacheGenericUpdate::TimelineUpdated {
579+
let _ = self.generic_update_sender.send(RoomEventCacheGenericUpdate::UpdateTimeline {
580580
room_id: self.room_id.clone(),
581581
});
582582
}
@@ -2253,7 +2253,7 @@ mod timed_tests {
22532253
// Just checking the generic update is correct.
22542254
assert_matches!(
22552255
generic_stream.recv().await,
2256-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: expected_room_id }) => {
2256+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: expected_room_id }) => {
22572257
assert_eq!(expected_room_id, room_id);
22582258
}
22592259
);
@@ -2329,7 +2329,7 @@ mod timed_tests {
23292329
// Just checking the generic update is correct.
23302330
assert_matches!(
23312331
generic_stream.recv().await,
2332-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: expected_room_id }) => {
2332+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: expected_room_id }) => {
23332333
assert_eq!(expected_room_id, room_id);
23342334
}
23352335
);
@@ -2495,12 +2495,12 @@ mod timed_tests {
24952495

24962496
// … same with a generic update.
24972497
assert_let_timeout!(
2498-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: received_room_id }) =
2498+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: received_room_id }) =
24992499
generic_stream.recv()
25002500
);
25012501
assert_eq!(received_room_id, room_id);
25022502
assert_let_timeout!(
2503-
Ok(RoomEventCacheGenericUpdate::Cleared { room_id: received_room_id }) =
2503+
Ok(RoomEventCacheGenericUpdate::Clear { room_id: received_room_id }) =
25042504
generic_stream.recv()
25052505
);
25062506
assert_eq!(received_room_id, room_id);
@@ -2607,7 +2607,7 @@ mod timed_tests {
26072607
// triggered.
26082608
assert_matches!(
26092609
generic_stream.recv().await,
2610-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: expected_room_id }) => {
2610+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: expected_room_id }) => {
26112611
assert_eq!(room_id, expected_room_id);
26122612
}
26132613
);
@@ -2640,7 +2640,7 @@ mod timed_tests {
26402640
// A generic update is triggered too.
26412641
assert_matches!(
26422642
generic_stream.recv().await,
2643-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: expected_room_id }) => {
2643+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: expected_room_id }) => {
26442644
assert_eq!(expected_room_id, room_id);
26452645
}
26462646
);
@@ -2768,7 +2768,7 @@ mod timed_tests {
27682768
// Just checking the generic update is correct.
27692769
assert_matches!(
27702770
generic_stream.recv().await,
2771-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: expected_room_id }) => {
2771+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: expected_room_id }) => {
27722772
assert_eq!(expected_room_id, room_id);
27732773
}
27742774
);
@@ -2829,7 +2829,7 @@ mod timed_tests {
28292829
// Just checking the generic update is correct.
28302830
assert_matches!(
28312831
generic_stream.recv().await,
2832-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: expected_room_id }) => {
2832+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: expected_room_id }) => {
28332833
assert_eq!(expected_room_id, room_id);
28342834
}
28352835
);
@@ -2936,7 +2936,7 @@ mod timed_tests {
29362936

29372937
// Same for the generic update.
29382938
assert_let_timeout!(
2939-
Ok(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: received_room_id }) =
2939+
Ok(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: received_room_id }) =
29402940
generic_stream.recv()
29412941
);
29422942
assert_eq!(received_room_id, room_id);

crates/matrix-sdk/src/latest_events/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ mod tests {
929929
// New event cache update, but the `LatestEvents` isn't listening to it.
930930
{
931931
room_event_cache_generic_update_sender
932-
.send(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: room_id.clone() })
932+
.send(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: room_id.clone() })
933933
.unwrap();
934934

935935
// Run the task.
@@ -952,7 +952,7 @@ mod tests {
952952
{
953953
room_registration_sender.send(RoomRegistration::Add(room_id.clone())).await.unwrap();
954954
room_event_cache_generic_update_sender
955-
.send(RoomEventCacheGenericUpdate::TimelineUpdated { room_id: room_id.clone() })
955+
.send(RoomEventCacheGenericUpdate::UpdateTimeline { room_id: room_id.clone() })
956956
.unwrap();
957957

958958
// Run the task to handle the `RoomRegistration` and the

0 commit comments

Comments
 (0)