#include "screens/comments/MentionParticipants.hpp" #include #include "spec/PostsSpec.hpp" #include "store/AppState.hpp" namespace dp { namespace { void collect(const Comment& c, std::vector& out) { out.push_back(&c.author); for (const Comment& child : c.children) collect(child, out); } } // namespace std::vector MentionParticipants::from(const User& postAuthor, const std::vector& comments) { std::vector authors{&postAuthor}; for (const Comment& c : comments) collect(c, authors); std::set seen; std::vector out; for (const User* author : authors) { if (out.size() >= spec::PostsLimits::kMaxMentionParticipants) break; if (AppState::instance().isCurrentUser(author->id)) continue; if (!seen.insert(author->id).second) continue; out.push_back({author->id, author->username, author->avatarSeed}); } return out; } } // namespace dp