Skip to content

Commit

Permalink
Reader: update list stream paging
Browse files Browse the repository at this point in the history
  • Loading branch information
eoigal committed Oct 4, 2024
1 parent dc9dd1d commit 182d124
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/reader/stream/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ class ReaderStream extends Component {
props.trackScrollPage( pageId );
}
const pageHandle = this.getPageHandle( stream.pageHandle, startDate );
console.log( 'fetchNextPage', { streamKey, stream, options, pageHandle, localeSlug } );
props.requestPage( { streamKey, pageHandle, localeSlug } );
};

Expand Down
14 changes: 11 additions & 3 deletions client/state/data-layer/wpcom/read/streams/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ const streamApis = {
return `/read/list/${ owner }/${ slug }/posts`;
},
dateProperty: 'date',
query: ( extras ) =>
getQueryString( {
...extras,
alg_prefix: 'read:recommendations:posts',
} ),
},
};

Expand All @@ -331,6 +336,7 @@ export function requestPage( action ) {
payload: { streamKey, streamType, pageHandle, isPoll, gap, localeSlug },
} = action;
const api = streamApis[ streamType ];
console.log( 'requestPage', pageHandle, api, action );

if ( ! api ) {
warn( `Unable to determine api path for ${ streamKey }` );
Expand All @@ -356,15 +362,17 @@ export function requestPage( action ) {
// There is a race condition in switchLocale when retrieving the language file
// The stream request can occur before the language file is loaded, so we need a way to explicitly set the lang in the request
const lang = localeSlug || i18n.getLocaleSlug();
const p = isPoll
? pollQuery( [], { ...algorithm } )
: query( { ...pageHandle, ...algorithm, number, lang }, action.payload );
console.log( 'p', p );

return http( {
method: 'GET',
path: path( { ...action.payload } ),
apiVersion,
apiNamespace: api.apiNamespace ?? null,
query: isPoll
? pollQuery( [], { ...algorithm } )
: query( { ...pageHandle, ...algorithm, number, lang }, action.payload ),
query: p,
onSuccess: action,
onFailure: action,
} );
Expand Down

0 comments on commit 182d124

Please sign in to comment.