0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2024-12-30 22:34:01 -05:00

Removed unused variables

This commit is contained in:
Ronald Langeveld 2024-12-17 17:12:15 +07:00
parent d68bd9375b
commit ddff3e850f

View file

@ -189,7 +189,7 @@ async function showComment({state, api, data: comment}: {state: EditableAppConte
}; };
} }
async function updateCommentLikeState({state, data: comment}: {state: EditableAppContext, data: {id: string, liked: boolean, commentsState: Comment[]}}) { async function updateCommentLikeState({state, data: comment}: {state: EditableAppContext, data: {id: string, liked: boolean}}) {
return { return {
comments: state.comments.map((c) => { comments: state.comments.map((c) => {
const replies = c.replies.map((r) => { const replies = c.replies.map((r) => {
@ -227,24 +227,24 @@ async function updateCommentLikeState({state, data: comment}: {state: EditableAp
}; };
} }
async function likeComment({state, api, data: comment, dispatchAction}: {state: EditableAppContext, api: GhostApi, data: {id: string}, dispatchAction: DispatchActionType}) { async function likeComment({api, data: comment, dispatchAction}: {state: EditableAppContext, api: GhostApi, data: {id: string}, dispatchAction: DispatchActionType}) {
dispatchAction('updateCommentLikeState', {id: comment.id, liked: true, commentsState: state.comments}); dispatchAction('updateCommentLikeState', {id: comment.id, liked: true});
try { try {
await api.comments.like({comment}); await api.comments.like({comment});
return {}; return {};
} catch (err) { } catch (err) {
dispatchAction('updateCommentLikeState', {id: comment.id, liked: false, commentsState: state.comments}); dispatchAction('updateCommentLikeState', {id: comment.id, liked: false});
} }
} }
async function unlikeComment({state, api, data: comment, dispatchAction}: {state: EditableAppContext, api: GhostApi, data: {id: string}, dispatchAction: DispatchActionType}) { async function unlikeComment({api, data: comment, dispatchAction}: {state: EditableAppContext, api: GhostApi, data: {id: string}, dispatchAction: DispatchActionType}) {
dispatchAction('updateCommentLikeState', {id: comment.id, liked: false, commentsState: state.comments}); dispatchAction('updateCommentLikeState', {id: comment.id, liked: false});
try { try {
await api.comments.unlike({comment}); await api.comments.unlike({comment});
return {}; return {};
} catch (err) { } catch (err) {
dispatchAction('updateCommentLikeState', {id: comment.id, liked: true, commentsState: state.comments}); dispatchAction('updateCommentLikeState', {id: comment.id, liked: true});
} }
} }