UNPKG

@replyke/core

Version:

Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.

24 lines 1.13 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var useCommentSection_1 = __importDefault(require("./useCommentSection")); function useGroupReplies(_a) { var commentId = _a.commentId; var entityCommentsTree = (0, useCommentSection_1.default)().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 }; } exports.default = useGroupReplies; //# sourceMappingURL=useGroupReplies.js.map