File tree 1 file changed +7
-2
lines changed
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> {
254
254
F : Fn ( & T ) -> S ,
255
255
S : Serialize ,
256
256
{
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.
258
259
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 ( ) )
260
263
{
261
264
return Ok ( None ) ;
262
265
}
263
266
267
+ // We also like to return None for next page when it's the first backward pagination.
264
268
let mut opts = IndexMap :: new ( ) ;
265
269
match self . options . page {
270
+ Page :: SeekBackward ( ref raw) if raw. is_empty ( ) => return Ok ( None ) ,
266
271
Page :: Unspecified | Page :: Seek ( _) | Page :: SeekBackward ( _) => {
267
272
let seek = f ( & self . records_and_total . last ( ) . unwrap ( ) . record ) ;
268
273
opts. insert ( "seek" . into ( ) , encode_seek ( seek) ?) ;
You can’t perform that action at this time.
0 commit comments