Repos
C++
1.6 KB34 lines Opens in site
Directory
Raw
Download
#pragma once
// Spec: INV-posts 3.1 (actions and API of FeedPostView). All mutate AppState.feed only; failures are logged, never
// shown (the feed card has no alert). Double tap voting and reactions are optimistic with rollback.
#include <functional>
#include <string>
#include <vector>
#include "model/Post.hpp"
#include "model/TargetType.hpp"
#include "model/UploadResponse.hpp"
#include "screens/comments/CommentRef.hpp"
namespace dp {
class FeedPostActions {
public:
// Own post: returns false (the caller opens the editor). Others: performVoteToggle(.post).
static bool doubleTapPost(const Post& post);
// Others' comments only; a double tap on an own comment edits it inside CommentView.
static void doubleTapComment(const CommentRef& comment);
static void deletePost(const Post& post);
static void reloadFeed();
static void deleteComment(const CommentRef& comment);
static void editComment(const CommentRef& comment, const std::string& content);
// done(true) when created, so the caller can clear the draft.
static void createComment(TargetType targetType, const std::string& targetId, const std::optional<std::string>& parentId,
const std::string& content, const std::vector<UploadResponse>& attachments, std::function<void(bool)> done);
static void reactPost(const Post& post, const std::string& emoji);
static void reactComment(const CommentRef& comment, const std::string& emoji);
// New count after a vote change: stars + new - old.
static std::int64_t votedCount(std::int64_t stars, Vote previous, Vote next) { return stars + next.value() - previous.value(); }
};
} // namespace dp