@@ -153,22 +153,13 @@ const completeSplitQuery =
153
153
* @param args - The arguments object for the query function, excluding
154
154
* the `paginationOpts` property. That property is injected by this hook.
155
155
* @param options - An object specifying the `initialNumItems` to be loaded in
156
- * the first page, and the `endCursorBehavior` to use.
157
- * @param options.endCursorBehavior` controls how the `endCursor` is set on the
158
- * last loaded page. The current behavior is to have the first request for a page
159
- * "pin" the end of the page to the `endCursor` returned in the first request.
160
- * This shows up as your first request growing as new items are added within
161
- * the range of the initial page. This is tracked via a QueryJournal, which is
162
- * not shared between clients and can have unexpected behavior, so we will be
163
- * deprecating this behavior in favor of the new option `setOnLoadMore`.
164
- * For `setOnLoadMore`, the `endCursor` is not inferred from the first request,
165
- * instead the first call to `loadMore` will explicitly set the `endCursor` to
166
- * the `continueCursor` of the last page. In the future this will not use the
167
- * QueryJournal and will become the default behavior, resulting in the first
168
- * page staying at the same size as `initialNumItems` until you call `loadMore`.
169
- * Note: setting the `endCursor` on the request will re-request that page with
170
- * the new argument, causing an effectively duplicate request per `loadMore`.
171
- *
156
+ * the first page, and the `latestPageSize` to use.
157
+ * @param options.latestPageSize controls how the latest page (the first page
158
+ * until another page is loaded) size grows. With "fixed", the page size will
159
+ * stay at the size specified by `initialNumItems` / `loadMore`. With "grow",
160
+ * the page size will grow as new items are added within the range of the initial
161
+ * page. Once multiple pages are loaded, all but the last page will grow, in
162
+ * order to provide seamless pagination. See the docs for more details.
172
163
* @returns A {@link UsePaginatedQueryResult} that includes the currently loaded
173
164
* items, the status of the pagination, and a `loadMore` function.
174
165
*
@@ -179,7 +170,7 @@ export function usePaginatedQuery<Query extends PaginatedQueryReference>(
179
170
args : PaginatedQueryArgs < Query > | "skip" ,
180
171
options : {
181
172
initialNumItems : number ;
182
- endCursorBehavior ?: "setOnLoadMore " | "legacyQueryJournal " ;
173
+ latestPageSize ?: "grow " | "fixed " ;
183
174
} ,
184
175
) : UsePaginatedQueryReturnType < Query > {
185
176
if (
@@ -256,9 +247,9 @@ export function usePaginatedQuery<Query extends PaginatedQueryReference>(
256
247
Value [ ] ,
257
248
undefined | PaginationResult < Value > ,
258
249
] = useMemo ( ( ) => {
259
- let currResult = undefined ;
250
+ let currResult : PaginationResult < Value > | undefined = undefined ;
260
251
261
- const allItems = [ ] ;
252
+ const allItems : Value [ ] = [ ] ;
262
253
for ( const pageKey of currState . pageKeys ) {
263
254
currResult = resultsObject [ pageKey ] ;
264
255
if ( currResult === undefined ) {
@@ -375,7 +366,7 @@ export function usePaginatedQuery<Query extends PaginatedQueryReference>(
375
366
const queries = { ...prevState . queries } ;
376
367
let ongoingSplits = prevState . ongoingSplits ;
377
368
let pageKeys = prevState . pageKeys ;
378
- if ( options . endCursorBehavior === "setOnLoadMore " ) {
369
+ if ( options . latestPageSize === "fixed " ) {
379
370
const lastPageKey = prevState . pageKeys . at ( - 1 ) ! ;
380
371
const boundLastPageKey = nextPageKey ;
381
372
queries [ boundLastPageKey ] = {
@@ -420,7 +411,7 @@ export function usePaginatedQuery<Query extends PaginatedQueryReference>(
420
411
}
421
412
} ,
422
413
} as const ;
423
- } , [ maybeLastResult , currState . nextPageKey , options . endCursorBehavior ] ) ;
414
+ } , [ maybeLastResult , currState . nextPageKey , options . latestPageSize ] ) ;
424
415
425
416
return {
426
417
results,
0 commit comments