Skip to content

Commit 8853be3

Browse files
committed
refactor(sdk): Remove SlidingSyncRoomInner::client.
This patch removes `SlidingSyncRoomInner::client` because, first off, it's not `Send`, and second, it's useless. Nobody uses it, it's basically dead code… annoying dead code… bad dead code!
1 parent 06d2961 commit 8853be3

File tree

5 files changed

+8
-32
lines changed

5 files changed

+8
-32
lines changed

crates/matrix-sdk/src/sliding_sync/cache.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,7 @@ pub(super) async fn restore_sliding_sync_state(
248248
restored_fields.rooms = frozen_rooms
249249
.into_iter()
250250
.map(|frozen_room| {
251-
(
252-
frozen_room.room_id.clone(),
253-
SlidingSyncRoom::from_frozen(frozen_room, client.clone()),
254-
)
251+
(frozen_room.room_id.clone(), SlidingSyncRoom::from_frozen(frozen_room))
255252
})
256253
.collect();
257254
}
@@ -355,11 +352,11 @@ mod tests {
355352

356353
rooms.insert(
357354
room_id1.clone(),
358-
SlidingSyncRoom::new(client.clone(), room_id1.clone(), None, Vec::new()),
355+
SlidingSyncRoom::new(room_id1.clone(), None, Vec::new()),
359356
);
360357
rooms.insert(
361358
room_id2.clone(),
362-
SlidingSyncRoom::new(client.clone(), room_id2.clone(), None, Vec::new()),
359+
SlidingSyncRoom::new(room_id2.clone(), None, Vec::new()),
363360
);
364361
}
365362

crates/matrix-sdk/src/sliding_sync/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Sliding Sync errors.
22
3+
use matrix_sdk_common::executor::JoinError;
34
use thiserror::Error;
4-
use tokio::task::JoinError;
55

66
/// Internal representation of errors in Sliding Sync.
77
#[derive(Error, Debug)]

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ impl SlidingSync {
359359
rooms_map.insert(
360360
room_id.clone(),
361361
SlidingSyncRoom::new(
362-
self.inner.client.clone(),
363362
room_id.clone(),
364363
room_data.prev_batch,
365364
timeline,
@@ -2313,7 +2312,6 @@ mod tests {
23132312
// it's not marked as initial in the response.
23142313
not_initial.to_owned(),
23152314
SlidingSyncRoom::new(
2316-
client.clone(),
23172315
no_overlap.to_owned(),
23182316
None,
23192317
vec![event_a.clone(), event_b.clone()],
@@ -2323,7 +2321,6 @@ mod tests {
23232321
// This has no events overlapping with the response timeline, hence limited.
23242322
no_overlap.to_owned(),
23252323
SlidingSyncRoom::new(
2326-
client.clone(),
23272324
no_overlap.to_owned(),
23282325
None,
23292326
vec![event_a.clone(), event_b.clone()],
@@ -2333,7 +2330,6 @@ mod tests {
23332330
// This has event_c in common with the response timeline.
23342331
partial_overlap.to_owned(),
23352332
SlidingSyncRoom::new(
2336-
client.clone(),
23372333
partial_overlap.to_owned(),
23382334
None,
23392335
vec![event_a.clone(), event_b.clone(), event_c.clone()],
@@ -2343,7 +2339,6 @@ mod tests {
23432339
// This has all events in common with the response timeline.
23442340
complete_overlap.to_owned(),
23452341
SlidingSyncRoom::new(
2346-
client.clone(),
23472342
partial_overlap.to_owned(),
23482343
None,
23492344
vec![event_c.clone(), event_d.clone()],
@@ -2354,7 +2349,6 @@ mod tests {
23542349
// limited.
23552350
no_remote_events.to_owned(),
23562351
SlidingSyncRoom::new(
2357-
client.clone(),
23582352
no_remote_events.to_owned(),
23592353
None,
23602354
vec![event_c.clone(), event_d.clone()],
@@ -2364,14 +2358,13 @@ mod tests {
23642358
// We don't have events for this room locally, and even if the remote room contains
23652359
// some events, it's not a limited sync.
23662360
no_local_events.to_owned(),
2367-
SlidingSyncRoom::new(client.clone(), no_local_events.to_owned(), None, vec![]),
2361+
SlidingSyncRoom::new(no_local_events.to_owned(), None, vec![]),
23682362
),
23692363
(
23702364
// Already limited, but would be marked limited if the flag wasn't ignored (same as
23712365
// partial overlap).
23722366
already_limited.to_owned(),
23732367
SlidingSyncRoom::new(
2374-
client,
23752368
already_limited.to_owned(),
23762369
None,
23772370
vec![event_a, event_b, event_c.clone()],

crates/matrix-sdk/src/sliding_sync/room.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ use matrix_sdk_base::{deserialized_responses::SyncTimelineEvent, sliding_sync::h
88
use ruma::{OwnedRoomId, RoomId};
99
use serde::{Deserialize, Serialize};
1010

11-
use crate::Client;
12-
1311
/// The state of a [`SlidingSyncRoom`].
1412
#[derive(Copy, Clone, Debug, Default, PartialEq)]
1513
pub enum SlidingSyncRoomState {
@@ -40,14 +38,12 @@ pub struct SlidingSyncRoom {
4038
impl SlidingSyncRoom {
4139
/// Create a new `SlidingSyncRoom`.
4240
pub fn new(
43-
client: Client,
4441
room_id: OwnedRoomId,
4542
prev_batch: Option<String>,
4643
timeline: Vec<SyncTimelineEvent>,
4744
) -> Self {
4845
Self {
4946
inner: Arc::new(SlidingSyncRoomInner {
50-
client,
5147
room_id,
5248
state: RwLock::new(SlidingSyncRoomState::NotLoaded),
5349
prev_batch: RwLock::new(prev_batch),
@@ -74,11 +70,6 @@ impl SlidingSyncRoom {
7470
self.inner.timeline_queue.read().unwrap().clone()
7571
}
7672

77-
/// Get a clone of the associated client.
78-
pub fn client(&self) -> Client {
79-
self.inner.client.clone()
80-
}
81-
8273
pub(super) fn update(
8374
&mut self,
8475
room_data: http::response::Room,
@@ -129,12 +120,11 @@ impl SlidingSyncRoom {
129120
*state = SlidingSyncRoomState::Loaded;
130121
}
131122

132-
pub(super) fn from_frozen(frozen_room: FrozenSlidingSyncRoom, client: Client) -> Self {
123+
pub(super) fn from_frozen(frozen_room: FrozenSlidingSyncRoom) -> Self {
133124
let FrozenSlidingSyncRoom { room_id, prev_batch, timeline_queue } = frozen_room;
134125

135126
Self {
136127
inner: Arc::new(SlidingSyncRoomInner {
137-
client,
138128
room_id,
139129
prev_batch: RwLock::new(prev_batch),
140130
state: RwLock::new(SlidingSyncRoomState::Preloaded),
@@ -157,9 +147,6 @@ impl SlidingSyncRoom {
157147

158148
#[derive(Debug)]
159149
struct SlidingSyncRoomInner {
160-
/// The client, used to fetch [`Room`][crate::Room].
161-
client: Client,
162-
163150
/// The room ID.
164151
room_id: OwnedRoomId,
165152

@@ -258,9 +245,8 @@ mod tests {
258245
timeline: Vec<SyncTimelineEvent>,
259246
) -> SlidingSyncRoom {
260247
let server = MockServer::start().await;
261-
let client = logged_in_client(Some(server.uri())).await;
262248

263-
SlidingSyncRoom::new(client, room_id.to_owned(), inner.prev_batch, timeline)
249+
SlidingSyncRoom::new(room_id.to_owned(), inner.prev_batch, timeline)
264250
}
265251

266252
#[async_test]

crates/matrix-sdk/src/sliding_sync/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl<T> Drop for AbortOnDrop<T> {
2323
}
2424
}
2525

26-
impl<T> Future for AbortOnDrop<T> {
26+
impl<T: 'static> Future for AbortOnDrop<T> {
2727
type Output = Result<T, JoinError>;
2828

2929
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {

0 commit comments

Comments
 (0)