Download wp-calypso/client/state/comments/selectors/comments-fetching-status.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/selectors/comments-fetching-status.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/comments/selectors/comments-fetching-status.js
-
curl -L -o comments-fetching-status.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/comments/selectors/comments-fetching-status.js
1.23 kB
| import { createSelector } from '@automattic/state-utils'; | |
| import { fetchStatusInitialState } from 'calypso/state/comments/reducer'; | |
| import { getPostCommentItems } from 'calypso/state/comments/selectors/get-post-comment-items'; | |
| import { getStateKey } from 'calypso/state/comments/utils'; | |
| import 'calypso/state/comments/init'; | |
| export const commentsFetchingStatus = createSelector( | |
| ( state, siteId, postId, commentTotal = 0 ) => { | |
| const fetchStatus = | |
| state.comments.fetchStatus[ getStateKey( siteId, postId ) ] ?? fetchStatusInitialState; | |
| const hasMoreComments = | |
| commentTotal > ( getPostCommentItems( state, siteId, postId )?.length ?? 0 ); | |
| return { | |
| haveEarlierCommentsToFetch: fetchStatus.before && hasMoreComments, | |
| haveLaterCommentsToFetch: fetchStatus.after && hasMoreComments, | |
| hasReceivedBefore: fetchStatus.hasReceivedBefore, | |
| hasReceivedAfter: fetchStatus.hasReceivedAfter, | |
| }; | |
| }, | |
| ( state, siteId, postId, commentTotal = 0 ) => { | |
| const fetchStatus = | |
| state.comments.fetchStatus[ getStateKey( siteId, postId ) ] ?? fetchStatusInitialState; | |
| const hasMoreComments = | |
| commentTotal > ( getPostCommentItems( state, siteId, postId )?.length ?? 0 ); | |
| return [ fetchStatus, hasMoreComments ]; | |
| } | |
| ); | |