Repos
C++
2.1 KB52 lines Opens in site
Directory
Raw
Download
#pragma once
// Spec: INV-posts 5.1 (CommentsView parameters). Callbacks are optional; an empty callback hides the matching control.
#include <functional>
#include <optional>
#include <string>
#include <vector>
#include "model/Comment.hpp"
#include "model/UploadResponse.hpp"
#include "model/UserSearch.hpp"
#include "screens/comments/CommentRef.hpp"
#include "screens/comments/CommentsSession.hpp"
#include "screens/post/PostEnvironment.hpp"
namespace dp {
struct CommentsProps {
const std::vector<Comment>* comments = nullptr;
int baseIndentationLevel = 0;
bool linksToProfile = true;
std::optional<std::size_t> maxAttachments;
std::function<void(const CommentRef&)> onSingleTap;
std::function<void(const CommentRef&)> onDoubleTap;
std::function<void(const CommentRef&, const std::string& emoji)> onReact;
std::function<void(const CommentRef&)> onDelete; // wired for own comments only
std::function<void(const CommentRef&, const std::string& content)> onEdit; // wired for own comments only
std::function<void(const CommentRef&)> onReply;
std::optional<std::string> replyingCommentId; // Comment.id() of the open reply composer
ui::Binding replyText;
std::function<void(const std::vector<UploadResponse>&)> onReplyAttachmentsChange;
std::function<void(const CommentRef&, const std::string& content)> onSubmitReply;
std::function<void()> onCancelReply;
std::vector<UserSearch::Result> mentionParticipants;
bool showsDividers = false;
bool showsLeadingDivider = false;
std::string rowAnchorPrefix; // when set, every row is marked with AnchorMark(prefix + Comment.id())
std::string composerAnchorKey; // AnchorMark key for the open composer
CommentsSession* session = nullptr; // required
PostEnvironment env;
};
// Flattened row of the tree: comment pointer and indentation level.
struct IndentedComment {
const Comment* comment;
int level;
};
// Depth first flatten, capped at PostsLimits::kMaxRenderedComments rows (comments.indented(startingAt:)).
std::vector<IndentedComment> flattenComments(const std::vector<Comment>& comments, int startingLevel);
} // namespace dp