@replyke/core
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
19 lines • 870 B
JavaScript
import useCommentSection from "./useCommentSection";
function useGroupReplies(_a) {
var commentId = _a.commentId;
var entityCommentsTree = useCommentSection().entityCommentsTree;
var commentData = entityCommentsTree[commentId];
if (!commentData) {
return { replies: [], newReplies: [] }; // If the commentID is not found, return an empty array
}
var allReplies = commentData.replies;
var replies = Object.values(allReplies).filter(function (reply) { return !reply.new; });
var newReplies = Object.values(allReplies)
.filter(function (reply) { return !!reply.new; })
.sort(function (a, b) {
return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
});
return { replies: replies, newReplies: newReplies };
}
export default useGroupReplies;
//# sourceMappingURL=useGroupReplies.js.map