mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Fixed pagination after new comments are added
This commit is contained in:
parent
5841241a42
commit
0390995d76
1 changed files with 6 additions and 1 deletions
|
@ -75,9 +75,14 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}) {
|
|||
|
||||
};
|
||||
|
||||
// To fix pagination when we create new comments (or people post comments after you loaded the page, we need to only load comments creatd AFTER the page load)
|
||||
let firstCommentsLoadedAt = null;
|
||||
|
||||
api.comments = {
|
||||
browse({page, postId}) {
|
||||
const filter = encodeURIComponent('post_id:' + postId);
|
||||
firstCommentsLoadedAt = firstCommentsLoadedAt ?? new Date().toISOString();
|
||||
|
||||
const filter = encodeURIComponent(`post_id:${postId}+created_at:<=${firstCommentsLoadedAt}`);
|
||||
const order = encodeURIComponent('created_at DESC');
|
||||
|
||||
const url = endpointFor({type: 'members', resource: 'comments', params: `?limit=5&include=member&order=${order}&filter=${filter}&page=${page}`});
|
||||
|
|
Loading…
Reference in a new issue