@@ -22,7 +22,7 @@ use matrix_sdk::attachment::{
22
22
AttachmentConfig , AttachmentInfo , BaseAudioInfo , BaseFileInfo , BaseImageInfo ,
23
23
BaseThumbnailInfo , BaseVideoInfo , Thumbnail ,
24
24
} ;
25
- use matrix_sdk_ui:: timeline:: { BackPaginationStatus , EventItemOrigin , Profile , TimelineDetails } ;
25
+ use matrix_sdk_ui:: timeline:: { EventItemOrigin , PaginationStatus , Profile , TimelineDetails } ;
26
26
use mime:: Mime ;
27
27
use ruma:: {
28
28
events:: {
@@ -162,7 +162,7 @@ impl Timeline {
162
162
163
163
pub fn subscribe_to_back_pagination_status (
164
164
& self ,
165
- listener : Box < dyn BackPaginationStatusListener > ,
165
+ listener : Box < dyn PaginationStatusListener > ,
166
166
) -> Result < Arc < TaskHandle > , ClientError > {
167
167
let mut subscriber = self . inner . back_pagination_status ( ) ;
168
168
@@ -176,11 +176,18 @@ impl Timeline {
176
176
} ) ) ) )
177
177
}
178
178
179
- /// Loads older messages into the timeline .
179
+ /// Paginate backwards, whether we are in focused mode or in live mode .
180
180
///
181
- /// Raises an exception if there are no timeline listeners.
182
- pub fn paginate_backwards ( & self , opts : PaginationOptions ) -> Result < ( ) , ClientError > {
183
- RUNTIME . block_on ( async { Ok ( self . inner . paginate_backwards ( opts. into ( ) ) . await ?) } )
181
+ /// Returns whether we hit the end of the timeline or not.
182
+ pub async fn paginate_backwards ( & self , num_events : u16 ) -> Result < bool , ClientError > {
183
+ Ok ( self . inner . paginate_backwards ( num_events) . await ?)
184
+ }
185
+
186
+ /// Paginate forwards, when in focused mode.
187
+ ///
188
+ /// Returns whether we hit the end of the timeline or not.
189
+ pub async fn paginate_forwards ( & self , num_events : u16 ) -> Result < bool , ClientError > {
190
+ Ok ( self . inner . focused_paginate_forwards ( num_events) . await ?)
184
191
}
185
192
186
193
pub fn send_read_receipt (
@@ -573,6 +580,18 @@ impl Timeline {
573
580
}
574
581
}
575
582
583
+ #[ derive( Debug , thiserror:: Error , uniffi:: Error ) ]
584
+ pub enum FocusEventError {
585
+ #[ error( "the event id parameter {event_id} is incorrect: {err}" ) ]
586
+ InvalidEventId { event_id : String , err : String } ,
587
+
588
+ #[ error( "the event {event_id} could not be found" ) ]
589
+ EventNotFound { event_id : String } ,
590
+
591
+ #[ error( "error when trying to focus on an event: {msg}" ) ]
592
+ Other { msg : String } ,
593
+ }
594
+
576
595
#[ derive( uniffi:: Record ) ]
577
596
pub struct RoomTimelineListenerResult {
578
597
pub items : Vec < Arc < TimelineItem > > ,
@@ -585,8 +604,8 @@ pub trait TimelineListener: Sync + Send {
585
604
}
586
605
587
606
#[ uniffi:: export( callback_interface) ]
588
- pub trait BackPaginationStatusListener : Sync + Send {
589
- fn on_update ( & self , status : BackPaginationStatus ) ;
607
+ pub trait PaginationStatusListener : Sync + Send {
608
+ fn on_update ( & self , status : PaginationStatus ) ;
590
609
}
591
610
592
611
#[ derive( Clone , uniffi:: Object ) ]
0 commit comments