Show poll expiry on hover

This commit is contained in:
blankie 2023-12-02 14:17:14 +11:00
parent d146ec3498
commit 1a02dc179c
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 8 additions and 3 deletions

View File

@ -472,6 +472,8 @@ static inline Element serialize_media(const Media& media) {
}
static inline Element serialize_poll(const httplib::Request& req, const Poll& poll) {
using namespace std::string_literals;
uint64_t voters_count = poll.voters_count >= 0 ? static_cast<uint64_t>(poll.voters_count) : poll.votes_count;
Element div("div");
@ -496,10 +498,13 @@ static inline Element serialize_poll(const httplib::Request& req, const Poll& po
: std::vector<Node>({std::to_string(poll.votes_count), " ", pick_form(poll.votes_count, "vote", "votes")})
);
if (poll.expired) {
p.nodes.push_back(" / Expired");
p.nodes.push_back(" / ");
p.nodes.push_back(Element("time", {{"datetime", to_rfc3339(poll.expires_at)}, {"title", "Expired on "s + full_time(poll.expires_at)}}, {"Expired"}));
} else if (poll.expires_at >= 0) {
p.nodes.push_back(" / Expires in ");
p.nodes.push_back(relative_time(current_time(), poll.expires_at));
p.nodes.push_back(" / ");
p.nodes.push_back(Element("time", {{"datetime", to_rfc3339(poll.expires_at)}, {"title", full_time(poll.expires_at)}}, {
"Expires in ", relative_time(current_time(), poll.expires_at),
}));
}
div.nodes.push_back(std::move(p));