#include "model/CommentTree.hpp" namespace dp { std::vector CommentTree::updatingVote(const std::vector& comments, const std::string& commentId, Vote vote) { std::vector out; out.reserve(comments.size()); for (const auto& comment : comments) { auto children = updatingVote(comment.children, commentId, vote); if (comment.data.id == commentId) out.push_back(comment.applyingVote(vote, children)); else out.push_back(comment.replacingChildren(children)); } return out; } std::vector CommentTree::updatingReaction(const std::vector& comments, const std::string& commentId, const std::string& emoji) { std::vector out; out.reserve(comments.size()); for (const auto& comment : comments) { auto children = updatingReaction(comment.children, commentId, emoji); if (comment.data.id == commentId) out.push_back(comment.replacingReactions(comment.reactions.toggling(emoji), children)); else out.push_back(comment.replacingChildren(children)); } return out; } } // namespace dp