Added rounding to Comments-UI API fetch timestamp (#19750)
no issue - allows for comments to be cached for 10s to greatly reduce the load hitting Ghost
This commit is contained in:
parent
afe1350008
commit
ef38316976
@ -122,7 +122,11 @@ function setupGhostApi({siteUrl = window.location.origin, apiUrl, apiKey}: {site
|
||||
return json;
|
||||
},
|
||||
browse({page, postId}: {page: number, postId: string}) {
|
||||
firstCommentsLoadedAt = firstCommentsLoadedAt ?? new Date().toISOString();
|
||||
// use the most recent round 10sec timestamp to fetch comments so we can have some caching
|
||||
const now = Date.now();
|
||||
const timestamp = (new Date(now - (now % 10000))).toISOString();
|
||||
|
||||
firstCommentsLoadedAt = firstCommentsLoadedAt ?? timestamp;
|
||||
|
||||
const filter = encodeURIComponent(`post_id:'${postId}'+created_at:<=${firstCommentsLoadedAt}`);
|
||||
const order = encodeURIComponent('created_at DESC, id DESC');
|
||||
|
Loading…
Reference in New Issue
Block a user