mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
Fixed delete/show on replies
This commit is contained in:
parent
09e2efe8fd
commit
165e84d8e0
@ -4,7 +4,7 @@ async function loadMoreComments({state, api}) {
|
|||||||
page = state.pagination.page + 1;
|
page = state.pagination.page + 1;
|
||||||
}
|
}
|
||||||
const data = await api.comments.browse({page, postId: state.postId});
|
const data = await api.comments.browse({page, postId: state.postId});
|
||||||
|
|
||||||
// Note: we store the comments from new to old, and show them in reverse order
|
// Note: we store the comments from new to old, and show them in reverse order
|
||||||
return {
|
return {
|
||||||
comments: [...state.comments, ...data.comments],
|
comments: [...state.comments, ...data.comments],
|
||||||
@ -22,7 +22,7 @@ async function addComment({state, api, data: comment}) {
|
|||||||
member: state.member,
|
member: state.member,
|
||||||
replies: []
|
replies: []
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
comments: [commentStructured, ...state.comments]
|
comments: [commentStructured, ...state.comments]
|
||||||
// todo: fix pagination now?
|
// todo: fix pagination now?
|
||||||
@ -41,7 +41,7 @@ async function addReply({state, api, data: {reply, parent}}) {
|
|||||||
...comment,
|
...comment,
|
||||||
member: state.member
|
member: state.member
|
||||||
};
|
};
|
||||||
|
|
||||||
// Replace the comment in the state with the new one
|
// Replace the comment in the state with the new one
|
||||||
return {
|
return {
|
||||||
comments: state.comments.map((c) => {
|
comments: state.comments.map((c) => {
|
||||||
@ -77,13 +77,29 @@ async function showComment({state, adminApi, data: comment}) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
comments: state.comments.map((c) => {
|
comments: state.comments.map((c) => {
|
||||||
|
const replies = c.replies.map((r) => {
|
||||||
|
if (r.id === comment.id) {
|
||||||
|
return {
|
||||||
|
...r,
|
||||||
|
status: 'published'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
});
|
||||||
|
|
||||||
if (c.id === comment.id) {
|
if (c.id === comment.id) {
|
||||||
return {
|
return {
|
||||||
...c,
|
...c,
|
||||||
status: 'published'
|
status: 'published',
|
||||||
|
replies
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return c;
|
|
||||||
|
return {
|
||||||
|
...c,
|
||||||
|
replies
|
||||||
|
};
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -132,13 +148,29 @@ async function deleteComment({state, api, data: comment}) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
comments: state.comments.map((c) => {
|
comments: state.comments.map((c) => {
|
||||||
|
const replies = c.replies.map((r) => {
|
||||||
|
if (r.id === comment.id) {
|
||||||
|
return {
|
||||||
|
...r,
|
||||||
|
status: 'deleted'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
});
|
||||||
|
|
||||||
if (c.id === comment.id) {
|
if (c.id === comment.id) {
|
||||||
return {
|
return {
|
||||||
...c,
|
...c,
|
||||||
status: 'deleted'
|
status: 'deleted',
|
||||||
|
replies
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return c;
|
|
||||||
|
return {
|
||||||
|
...c,
|
||||||
|
replies
|
||||||
|
};
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -165,7 +197,7 @@ async function editComment({state, api, data: {comment, parent}}) {
|
|||||||
} else if (c.id === comment.id) {
|
} else if (c.id === comment.id) {
|
||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user