show animated reactions
This commit is contained in:
@@ -620,7 +620,11 @@ Gtk::Widget *ChatMessageItemContainer::CreateReactionsComponent(const Message &d
|
|||||||
} else { // custom
|
} else { // custom
|
||||||
ev->set_tooltip_text(reaction.Emoji.Name);
|
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);
|
img->set_can_focus(false);
|
||||||
box->add(*img);
|
box->add(*img);
|
||||||
}
|
}
|
||||||
|
@@ -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) {
|
std::string EmojiData::URLFromID(const Glib::ustring &emoji_id, const char *ext, const char *size) {
|
||||||
return URLFromID(emoji_id.raw(), ext, size);
|
return URLFromID(emoji_id.raw(), ext, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EmojiData::IsEmojiAnimated() const noexcept {
|
||||||
|
return IsAnimated.has_value() && *IsAnimated;
|
||||||
|
}
|
||||||
|
@@ -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(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(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);
|
static std::string URLFromID(const Glib::ustring &emoji_id, const char *ext = "png", const char *size = nullptr);
|
||||||
|
|
||||||
|
bool IsEmojiAnimated() const noexcept;
|
||||||
};
|
};
|
||||||
|
@@ -1056,11 +1056,12 @@ Message Store::GetMessageBound(std::unique_ptr<Statement> &s) const {
|
|||||||
while (s->FetchOne()) {
|
while (s->FetchOne()) {
|
||||||
size_t idx;
|
size_t idx;
|
||||||
ReactionData q;
|
ReactionData q;
|
||||||
s->Get(0, q.Emoji.ID);
|
s->Get(0, q.Count);
|
||||||
s->Get(1, q.Emoji.Name);
|
s->Get(1, q.HasReactedWith);
|
||||||
s->Get(2, q.Count);
|
s->Get(2, idx);
|
||||||
s->Get(3, q.HasReactedWith);
|
s->Get(3, q.Emoji.ID);
|
||||||
s->Get(4, idx);
|
s->Get(4, q.Emoji.Name);
|
||||||
|
s->Get(5, q.Emoji.IsAnimated);
|
||||||
tmp[idx] = q;
|
tmp[idx] = q;
|
||||||
}
|
}
|
||||||
s->Reset();
|
s->Reset();
|
||||||
@@ -2291,7 +2292,19 @@ bool Store::CreateStatements() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_stmt_get_reactions = std::make_unique<Statement>(m_db, R"(
|
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()) {
|
if (!m_stmt_get_reactions->OK()) {
|
||||||
fprintf(stderr, "failed to prepare get reactions statement: %s\n", m_db.ErrStr());
|
fprintf(stderr, "failed to prepare get reactions statement: %s\n", m_db.ErrStr());
|
||||||
|
Reference in New Issue
Block a user