@@ -21,16 +21,17 @@ use eyeball_im_util::vector::{FilterMap, VectorObserverExt};
21
21
use futures_core:: Stream ;
22
22
use imbl:: Vector ;
23
23
#[ cfg( test) ]
24
- use matrix_sdk:: crypto :: OlmMachine ;
24
+ use matrix_sdk:: Result ;
25
25
use matrix_sdk:: {
26
- Result , Room ,
27
26
deserialized_responses:: TimelineEvent ,
28
27
event_cache:: { RoomEventCache , RoomPaginationStatus } ,
29
28
paginators:: { PaginationResult , Paginator } ,
30
29
send_queue:: {
31
30
LocalEcho , LocalEchoContent , RoomSendQueueUpdate , SendHandle , SendReactionHandle ,
32
31
} ,
33
32
} ;
33
+ #[ cfg( test) ]
34
+ use ruma:: events:: receipt:: ReceiptEventContent ;
34
35
use ruma:: {
35
36
EventId , MilliSecondsSinceUnixEpoch , OwnedEventId , OwnedTransactionId , TransactionId , UserId ,
36
37
api:: client:: receipt:: create_receipt:: v3:: ReceiptType as SendReceiptType ,
@@ -46,8 +47,6 @@ use ruma::{
46
47
room_version_rules:: RoomVersionRules ,
47
48
serde:: Raw ,
48
49
} ;
49
- #[ cfg( test) ]
50
- use ruma:: { OwnedRoomId , RoomId , events:: receipt:: ReceiptEventContent } ;
51
50
use tokio:: sync:: { RwLock , RwLockWriteGuard } ;
52
51
use tracing:: { debug, error, field:: debug, info, instrument, trace, warn} ;
53
52
@@ -68,11 +67,11 @@ use super::{
68
67
event_item:: { ReactionStatus , RemoteEventOrigin } ,
69
68
item:: TimelineUniqueId ,
70
69
subscriber:: TimelineSubscriber ,
71
- traits:: { Decryptor , RoomDataProvider } ,
70
+ traits:: RoomDataProvider ,
72
71
} ;
73
72
use crate :: {
74
73
timeline:: {
75
- MsgLikeContent , MsgLikeKind , TimelineEventFilterFn ,
74
+ MsgLikeContent , MsgLikeKind , Room , TimelineEventFilterFn ,
76
75
algorithms:: rfind_event_by_item_id,
77
76
date_dividers:: DateDividerAdjuster ,
78
77
event_item:: TimelineItemHandle ,
@@ -152,7 +151,7 @@ impl<P: RoomDataProvider> TimelineFocusKind<P> {
152
151
}
153
152
154
153
#[ derive( Clone , Debug ) ]
155
- pub ( super ) struct TimelineController < P : RoomDataProvider = Room , D : Decryptor = Room > {
154
+ pub ( super ) struct TimelineController < P : RoomDataProvider = Room > {
156
155
/// Inner mutable state.
157
156
state : Arc < RwLock < TimelineState < P > > > ,
158
157
@@ -161,15 +160,16 @@ pub(super) struct TimelineController<P: RoomDataProvider = Room, D: Decryptor =
161
160
162
161
/// A [`RoomDataProvider`] implementation, providing data.
163
162
///
164
- /// Useful for testing only; in the real world, it's just a [`Room`].
163
+ /// The type is a `RoomDataProvider` to allow testing. In the real world,
164
+ /// this would normally be a [`Room`].
165
165
pub ( crate ) room_data_provider : P ,
166
166
167
167
/// Settings applied to this timeline.
168
168
pub ( super ) settings : TimelineSettings ,
169
169
170
170
/// Long-running task used to retry decryption of timeline items without
171
171
/// blocking main processing.
172
- decryption_retry_task : DecryptionRetryTask < P , D > ,
172
+ decryption_retry_task : DecryptionRetryTask < P , P > ,
173
173
}
174
174
175
175
#[ derive( Clone ) ]
@@ -290,7 +290,7 @@ pub fn default_event_filter(event: &AnySyncTimelineEvent, rules: &RoomVersionRul
290
290
}
291
291
}
292
292
293
- impl < P : RoomDataProvider , D : Decryptor > TimelineController < P , D > {
293
+ impl < P : RoomDataProvider > TimelineController < P > {
294
294
pub ( super ) fn new (
295
295
room_data_provider : P ,
296
296
focus : TimelineFocus ,
@@ -1103,12 +1103,10 @@ impl<P: RoomDataProvider, D: Decryptor> TimelineController<P, D> {
1103
1103
true
1104
1104
}
1105
1105
1106
- async fn retry_event_decryption_inner (
1107
- & self ,
1108
- decryptor : D ,
1109
- session_ids : Option < BTreeSet < String > > ,
1110
- ) {
1111
- self . decryption_retry_task . decrypt ( decryptor, session_ids, self . settings . clone ( ) ) . await ;
1106
+ pub ( crate ) async fn retry_event_decryption_inner ( & self , session_ids : Option < BTreeSet < String > > ) {
1107
+ self . decryption_retry_task
1108
+ . decrypt ( self . room_data_provider . clone ( ) , session_ids, self . settings . clone ( ) )
1109
+ . await ;
1112
1110
}
1113
1111
1114
1112
pub ( super ) async fn set_sender_profiles_pending ( & self ) {
@@ -1250,7 +1248,7 @@ impl<P: RoomDataProvider, D: Decryptor> TimelineController<P, D> {
1250
1248
/// Subscribe to changes in the read receipts of our own user.
1251
1249
pub async fn subscribe_own_user_read_receipts_changed (
1252
1250
& self ,
1253
- ) -> impl Stream < Item = ( ) > + use < P , D > {
1251
+ ) -> impl Stream < Item = ( ) > + use < P > {
1254
1252
self . state . read ( ) . await . meta . read_receipts . subscribe_own_user_read_receipts_changed ( )
1255
1253
}
1256
1254
@@ -1604,7 +1602,7 @@ impl TimelineController {
1604
1602
1605
1603
#[ instrument( skip( self ) , fields( room_id = ?self . room( ) . room_id( ) ) ) ]
1606
1604
pub ( super ) async fn retry_event_decryption ( & self , session_ids : Option < BTreeSet < String > > ) {
1607
- self . retry_event_decryption_inner ( self . room ( ) . clone ( ) , session_ids) . await
1605
+ self . retry_event_decryption_inner ( session_ids) . await
1608
1606
}
1609
1607
1610
1608
/// Combine the global (event cache) pagination status with the local state
@@ -1638,18 +1636,6 @@ impl TimelineController {
1638
1636
}
1639
1637
}
1640
1638
1641
- #[ cfg( test) ]
1642
- impl < P : RoomDataProvider > TimelineController < P , ( OlmMachine , OwnedRoomId ) > {
1643
- pub ( super ) async fn retry_event_decryption_test (
1644
- & self ,
1645
- room_id : & RoomId ,
1646
- olm_machine : OlmMachine ,
1647
- session_ids : Option < BTreeSet < String > > ,
1648
- ) {
1649
- self . retry_event_decryption_inner ( ( olm_machine, room_id. to_owned ( ) ) , session_ids) . await
1650
- }
1651
- }
1652
-
1653
1639
#[ allow( clippy:: too_many_arguments) ]
1654
1640
async fn fetch_replied_to_event < P : RoomDataProvider > (
1655
1641
mut state_guard : RwLockWriteGuard < ' _ , TimelineState < P > > ,
0 commit comments