@@ -22,6 +22,7 @@ use itertools::Itertools;
22
22
use matrix_sdk:: { Client , Error , executor:: AbortOnDrop , locks:: Mutex , paginators:: PaginationToken } ;
23
23
use matrix_sdk_common:: executor:: spawn;
24
24
use ruma:: { OwnedRoomId , api:: client:: space:: get_hierarchy, uint} ;
25
+ use tokio:: sync:: Mutex as AsyncMutex ;
25
26
use tracing:: error;
26
27
27
28
use crate :: spaces:: SpaceRoom ;
@@ -98,7 +99,7 @@ pub struct SpaceRoomList {
98
99
99
100
parent_space_id : OwnedRoomId ,
100
101
101
- token : Mutex < PaginationToken > ,
102
+ token : AsyncMutex < PaginationToken > ,
102
103
103
104
pagination_state : SharedObservable < SpaceRoomListPaginationState > ,
104
105
@@ -155,7 +156,7 @@ impl SpaceRoomList {
155
156
Self {
156
157
client,
157
158
parent_space_id,
158
- token : Mutex :: new ( None . into ( ) ) ,
159
+ token : AsyncMutex :: new ( None . into ( ) ) ,
159
160
pagination_state : SharedObservable :: new ( SpaceRoomListPaginationState :: Idle {
160
161
end_reached : false ,
161
162
} ) ,
@@ -206,14 +207,15 @@ impl SpaceRoomList {
206
207
let mut request = get_hierarchy:: v1:: Request :: new ( self . parent_space_id . clone ( ) ) ;
207
208
request. max_depth = Some ( uint ! ( 1 ) ) ; // We only want the immediate children of the space
208
209
209
- if let PaginationToken :: HasMore ( ref token) = * self . token . lock ( ) {
210
+ let mut pagination_token = self . token . lock ( ) . await ;
211
+
212
+ if let PaginationToken :: HasMore ( ref token) = * pagination_token {
210
213
request. from = Some ( token. clone ( ) ) ;
211
214
}
212
215
213
216
match self . client . send ( request) . await {
214
217
Ok ( result) => {
215
- let mut token = self . token . lock ( ) ;
216
- * token = match & result. next_batch {
218
+ * pagination_token = match & result. next_batch {
217
219
Some ( val) => PaginationToken :: HasMore ( val. clone ( ) ) ,
218
220
None => PaginationToken :: HitEnd ,
219
221
} ;
0 commit comments