File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -254,15 +254,20 @@ impl<T> Paginated<T> {
254254 F : Fn ( & T ) -> S ,
255255 S : Serialize ,
256256 {
257- // TODO: handle this more properly when seek backward comes into play.
257+ // When the data size is smaller than the page size, we would expect the next page to be
258+ // available during backward pagination but unavailable during forward pagination.
258259 if self . options . is_explicit ( )
259- || self . records_and_total . len ( ) < self . options . per_page as usize
260+ || self . records_and_total . is_empty ( )
261+ || ( self . records_and_total . len ( ) < self . options . per_page as usize
262+ && !self . options . is_backward ( ) )
260263 {
261264 return Ok ( None ) ;
262265 }
263266
267+ // We also like to return None for next page when it's the first backward pagination.
264268 let mut opts = IndexMap :: new ( ) ;
265269 match self . options . page {
270+ Page :: SeekBackward ( ref raw) if raw. is_empty ( ) => return Ok ( None ) ,
266271 Page :: Unspecified | Page :: Seek ( _) | Page :: SeekBackward ( _) => {
267272 let seek = f ( & self . records_and_total . last ( ) . unwrap ( ) . record ) ;
268273 opts. insert ( "seek" . into ( ) , encode_seek ( seek) ?) ;
You can’t perform that action at this time.
0 commit comments