0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Add comments loading state action (#21834)

ref https://github.com/TryGhost/Ghost/pull/21788#discussion_r1869802093

- Introduced `setCommentsIsLoading` action to handle the loading state
of comments dynamically.
- Updated `setOrder` function to dispatch the `setCommentsIsLoading`
action, ensuring proper UI feedback during asynchronous operations.
This commit is contained in:
Ronald Langeveld 2024-12-09 16:09:14 +08:00 committed by GitHub
parent 2f7b151f15
commit dbcbabb99a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,8 +22,14 @@ async function loadMoreComments({state, api, options, order}: {state: EditableAp
}; };
} }
async function setOrder({state, data: {order}, options, api}: {state: EditableAppContext, data: {order: string}, options: CommentsOptions, api: GhostApi}) { function setCommentsIsLoading({data: isLoading}: {data: boolean | null}) {
state.commentsIsLoading = true; return {
commentsIsLoading: isLoading
};
}
async function setOrder({state, data: {order}, options, api, dispatchAction}: {state: EditableAppContext, data: {order: string}, options: CommentsOptions, api: GhostApi, dispatchAction: DispatchActionType}) {
dispatchAction('setCommentsIsLoading', true);
try { try {
let data; let data;
@ -474,7 +480,8 @@ export const Actions = {
setOrder, setOrder,
openCommentForm, openCommentForm,
highlightComment, highlightComment,
setHighlightComment setHighlightComment,
setCommentsIsLoading
}; };
export type ActionType = keyof typeof Actions; export type ActionType = keyof typeof Actions;