@@ -12,9 +12,7 @@ use matrix_sdk::{
12
12
use matrix_sdk_base:: deserialized_responses:: TimelineEvent ;
13
13
use matrix_sdk_test:: { async_test, JoinedRoomBuilder , StateTestEvent , SyncResponseBuilder , BOB } ;
14
14
use matrix_sdk_ui:: {
15
- timeline:: {
16
- RoomExt , TimelineFocus , TimelineItemContent , MAX_PINNED_EVENTS_CONCURRENT_REQUESTS ,
17
- } ,
15
+ timeline:: { RoomExt , TimelineFocus , TimelineItemContent } ,
18
16
Timeline ,
19
17
} ;
20
18
use ruma:: {
@@ -53,7 +51,10 @@ async fn test_new_pinned_events_are_added_on_sync() {
53
51
54
52
let room = test_helper. client . get_room ( & room_id) . unwrap ( ) ;
55
53
let timeline = Timeline :: builder ( & room)
56
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 100 } )
54
+ . with_focus ( TimelineFocus :: PinnedEvents {
55
+ max_events_to_load : 100 ,
56
+ max_concurrent_requests : 10 ,
57
+ } )
57
58
. build ( )
58
59
. await
59
60
. unwrap ( ) ;
@@ -138,7 +139,10 @@ async fn test_new_pinned_event_ids_reload_the_timeline() {
138
139
139
140
let room = test_helper. client . get_room ( & room_id) . unwrap ( ) ;
140
141
let timeline = Timeline :: builder ( & room)
141
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 100 } )
142
+ . with_focus ( TimelineFocus :: PinnedEvents {
143
+ max_events_to_load : 100 ,
144
+ max_concurrent_requests : 10 ,
145
+ } )
142
146
. build ( )
143
147
. await
144
148
. unwrap ( ) ;
@@ -210,7 +214,10 @@ async fn test_max_events_to_load_is_honored() {
210
214
211
215
let room = test_helper. client . get_room ( & room_id) . unwrap ( ) ;
212
216
let ret = Timeline :: builder ( & room)
213
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 1 } )
217
+ . with_focus ( TimelineFocus :: PinnedEvents {
218
+ max_events_to_load : 1 ,
219
+ max_concurrent_requests : 10 ,
220
+ } )
214
221
. build ( )
215
222
. await ;
216
223
@@ -249,7 +256,10 @@ async fn test_cached_events_are_kept_for_different_room_instances() {
249
256
let room = test_helper. client . get_room ( & room_id) . unwrap ( ) ;
250
257
let ( room_cache, _drop_handles) = room. event_cache ( ) . await . unwrap ( ) ;
251
258
let timeline = Timeline :: builder ( & room)
252
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 2 } )
259
+ . with_focus ( TimelineFocus :: PinnedEvents {
260
+ max_events_to_load : 2 ,
261
+ max_concurrent_requests : 10 ,
262
+ } )
253
263
. build ( )
254
264
. await
255
265
. unwrap ( ) ;
@@ -281,7 +291,10 @@ async fn test_cached_events_are_kept_for_different_room_instances() {
281
291
282
292
// And a new timeline one
283
293
let timeline = Timeline :: builder ( & room)
284
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 2 } )
294
+ . with_focus ( TimelineFocus :: PinnedEvents {
295
+ max_events_to_load : 2 ,
296
+ max_concurrent_requests : 10 ,
297
+ } )
285
298
. build ( )
286
299
. await
287
300
. unwrap ( ) ;
@@ -305,7 +318,10 @@ async fn test_cached_events_are_kept_for_different_room_instances() {
305
318
306
319
// And a new timeline one
307
320
let ret = Timeline :: builder ( & room)
308
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 2 } )
321
+ . with_focus ( TimelineFocus :: PinnedEvents {
322
+ max_events_to_load : 2 ,
323
+ max_concurrent_requests : 10 ,
324
+ } )
309
325
. build ( )
310
326
. await ;
311
327
@@ -331,7 +347,10 @@ async fn test_pinned_timeline_with_pinned_event_ids_and_empty_result_fails() {
331
347
332
348
let room = test_helper. client . get_room ( & room_id) . unwrap ( ) ;
333
349
let ret = Timeline :: builder ( & room)
334
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 1 } )
350
+ . with_focus ( TimelineFocus :: PinnedEvents {
351
+ max_events_to_load : 1 ,
352
+ max_concurrent_requests : 10 ,
353
+ } )
335
354
. build ( )
336
355
. await ;
337
356
@@ -355,7 +374,10 @@ async fn test_pinned_timeline_with_no_pinned_event_ids_is_just_empty() {
355
374
356
375
let room = test_helper. client . get_room ( & room_id) . unwrap ( ) ;
357
376
let timeline = Timeline :: builder ( & room)
358
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 1 } )
377
+ . with_focus ( TimelineFocus :: PinnedEvents {
378
+ max_events_to_load : 1 ,
379
+ max_concurrent_requests : 10 ,
380
+ } )
359
381
. build ( )
360
382
. await
361
383
. unwrap ( ) ;
@@ -390,7 +412,10 @@ async fn test_edited_events_are_reflected_in_sync() {
390
412
391
413
let room = test_helper. client . get_room ( & room_id) . unwrap ( ) ;
392
414
let timeline = Timeline :: builder ( & room)
393
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 100 } )
415
+ . with_focus ( TimelineFocus :: PinnedEvents {
416
+ max_events_to_load : 100 ,
417
+ max_concurrent_requests : 10 ,
418
+ } )
394
419
. build ( )
395
420
. await
396
421
. unwrap ( ) ;
@@ -469,7 +494,10 @@ async fn test_redacted_events_are_reflected_in_sync() {
469
494
470
495
let room = test_helper. client . get_room ( & room_id) . unwrap ( ) ;
471
496
let timeline = Timeline :: builder ( & room)
472
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 100 } )
497
+ . with_focus ( TimelineFocus :: PinnedEvents {
498
+ max_events_to_load : 100 ,
499
+ max_concurrent_requests : 10 ,
500
+ } )
473
501
. build ( )
474
502
. await
475
503
. unwrap ( ) ;
@@ -539,7 +567,10 @@ async fn test_edited_events_survive_pinned_event_ids_change() {
539
567
540
568
let room = test_helper. client . get_room ( & room_id) . unwrap ( ) ;
541
569
let timeline = Timeline :: builder ( & room)
542
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 100 } )
570
+ . with_focus ( TimelineFocus :: PinnedEvents {
571
+ max_events_to_load : 100 ,
572
+ max_concurrent_requests : 10 ,
573
+ } )
543
574
. build ( )
544
575
. await
545
576
. unwrap ( ) ;
@@ -648,6 +679,8 @@ async fn test_ensure_max_concurrency_is_observed() {
648
679
649
680
let pinned_event_ids: Vec < String > = ( 0 ..100 ) . map ( |idx| format ! ( "${idx}" ) ) . collect ( ) ;
650
681
682
+ let max_concurrent_requests: u16 = 10 ;
683
+
651
684
let joined_room_builder = JoinedRoomBuilder :: new ( & room_id)
652
685
// Set up encryption
653
686
. add_state_event ( StateTestEvent :: Encryption )
@@ -681,7 +714,7 @@ async fn test_ensure_max_concurrency_is_observed() {
681
714
. set_body_json ( pinned_event. json ( ) ) ,
682
715
)
683
716
// Verify this endpoint is only called the max concurrent amount of times.
684
- . expect ( MAX_PINNED_EVENTS_CONCURRENT_REQUESTS as u64 )
717
+ . expect ( max_concurrent_requests as u64 )
685
718
. mount ( & server)
686
719
. await ;
687
720
@@ -696,9 +729,10 @@ async fn test_ensure_max_concurrency_is_observed() {
696
729
697
730
// Start loading the pinned event timeline asynchronously.
698
731
let handle = tokio:: spawn ( {
699
- let timeline_builder = room
700
- . timeline_builder ( )
701
- . with_focus ( TimelineFocus :: PinnedEvents { max_events_to_load : 100 } ) ;
732
+ let timeline_builder = room. timeline_builder ( ) . with_focus ( TimelineFocus :: PinnedEvents {
733
+ max_events_to_load : 100 ,
734
+ max_concurrent_requests : 10 ,
735
+ } ) ;
702
736
async {
703
737
let _ = timeline_builder. build ( ) . await ;
704
738
}
0 commit comments