show animated reactions

This commit is contained in:
ouwou 2023-11-04 20:54:15 -04:00
parent 4774711f52
commit 5703d06c73
4 changed files with 30 additions and 7 deletions

View File

@ -620,7 +620,11 @@ Gtk::Widget *ChatMessageItemContainer::CreateReactionsComponent(const Message &d
} else { // custom
ev->set_tooltip_text(reaction.Emoji.Name);
auto img = Gtk::manage(new LazyImage(reaction.Emoji.GetURL(), 16, 16));
auto *img = Gtk::make_managed<LazyImage>(reaction.Emoji.GetURL(), 16, 16);
if (reaction.Emoji.IsEmojiAnimated() && Abaddon::Get().GetSettings().ShowAnimations) {
img->SetURL(reaction.Emoji.GetURL("gif"));
img->SetAnimated(true);
}
img->set_can_focus(false);
box->add(*img);
}

View File

@ -49,3 +49,7 @@ std::string EmojiData::URLFromID(Snowflake emoji_id, const char *ext, const char
std::string EmojiData::URLFromID(const Glib::ustring &emoji_id, const char *ext, const char *size) {
return URLFromID(emoji_id.raw(), ext, size);
}
bool EmojiData::IsEmojiAnimated() const noexcept {
return IsAnimated.has_value() && *IsAnimated;
}

View File

@ -22,4 +22,6 @@ struct EmojiData {
static std::string URLFromID(const std::string &emoji_id, const char *ext = "png", const char *size = nullptr);
static std::string URLFromID(Snowflake emoji_id, const char *ext = "png", const char *size = nullptr);
static std::string URLFromID(const Glib::ustring &emoji_id, const char *ext = "png", const char *size = nullptr);
bool IsEmojiAnimated() const noexcept;
};

View File

@ -1056,11 +1056,12 @@ Message Store::GetMessageBound(std::unique_ptr<Statement> &s) const {
while (s->FetchOne()) {
size_t idx;
ReactionData q;
s->Get(0, q.Emoji.ID);
s->Get(1, q.Emoji.Name);
s->Get(2, q.Count);
s->Get(3, q.HasReactedWith);
s->Get(4, idx);
s->Get(0, q.Count);
s->Get(1, q.HasReactedWith);
s->Get(2, idx);
s->Get(3, q.Emoji.ID);
s->Get(4, q.Emoji.Name);
s->Get(5, q.Emoji.IsAnimated);
tmp[idx] = q;
}
s->Reset();
@ -2291,7 +2292,19 @@ bool Store::CreateStatements() {
}
m_stmt_get_reactions = std::make_unique<Statement>(m_db, R"(
SELECT emoji_id, name, count, me, idx FROM reactions WHERE message = ?
SELECT
reactions.count,
reactions.me,
reactions.idx,
emojis.id,
emojis.name,
emojis.animated
FROM
reactions
INNER JOIN
emojis ON reactions.emoji_id = emojis.id
WHERE
message = ?
)");
if (!m_stmt_get_reactions->OK()) {
fprintf(stderr, "failed to prepare get reactions statement: %s\n", m_db.ErrStr());