add: emojis is_animated

This commit is contained in:
trisua 2025-05-05 23:27:05 -04:00
parent 8e88cbbc6f
commit 570a290954
4 changed files with 19 additions and 5 deletions

View file

@ -1148,7 +1148,10 @@ secondary=false) -%}
.querySelector("emoji-picker") .querySelector("emoji-picker")
.addEventListener("emoji-click", (event) => { .addEventListener("emoji-click", (event) => {
function gemoji() { function gemoji() {
const use_first_shortcode = ["grinning squinting face"]; const use_first_shortcode = [
"grinning squinting face",
"smiling_face_with_heart_eyes",
];
if ( if (
use_first_shortcode.includes( use_first_shortcode.includes(

View file

@ -4,5 +4,6 @@ CREATE TABLE IF NOT EXISTS emojis (
owner BIGINT NOT NULL, owner BIGINT NOT NULL,
community BIGINT NOT NULL, community BIGINT NOT NULL,
upload_id BIGINT NOT NULL, upload_id BIGINT NOT NULL,
name TEXT NOT NULL name TEXT NOT NULL,
is_animated INT NOT NULL
) )

View file

@ -25,6 +25,7 @@ impl DataManager {
community: get!(x->3(i64)) as usize, community: get!(x->3(i64)) as usize,
upload_id: get!(x->4(i64)) as usize, upload_id: get!(x->4(i64)) as usize,
name: get!(x->5(String)), name: get!(x->5(String)),
is_animated: get!(x->6(i32)) as i8 == 1,
} }
} }
@ -125,14 +126,15 @@ impl DataManager {
let res = execute!( let res = execute!(
&conn, &conn,
"INSERT INTO emojis VALUES ($1, $2, $3, $4, $5, $6)", "INSERT INTO emojis VALUES ($1, $2, $3, $4, $5, $6, $7)",
params![ params![
&(data.id as i64), &(data.id as i64),
&(data.owner as i64), &(data.owner as i64),
&(data.created as i64), &(data.created as i64),
&(data.community as i64), &(data.community as i64),
&(data.upload_id as i64), &(data.upload_id as i64),
&data.name &data.name,
&{ if data.is_animated { 1 } else { 0 } },
] ]
); );

View file

@ -46,13 +46,20 @@ pub struct CustomEmoji {
pub community: usize, pub community: usize,
pub upload_id: usize, pub upload_id: usize,
pub name: String, pub name: String,
pub is_animated: bool,
} }
pub type EmojiParserResult = Vec<(String, usize, String)>; pub type EmojiParserResult = Vec<(String, usize, String)>;
impl CustomEmoji { impl CustomEmoji {
/// Create a new [`CustomEmoji`]. /// Create a new [`CustomEmoji`].
pub fn new(owner: usize, community: usize, upload_id: usize, name: String) -> Self { pub fn new(
owner: usize,
community: usize,
upload_id: usize,
name: String,
is_animated: bool,
) -> Self {
Self { Self {
id: AlmostSnowflake::new(1234567890) id: AlmostSnowflake::new(1234567890)
.to_string() .to_string()
@ -63,6 +70,7 @@ impl CustomEmoji {
community, community,
upload_id, upload_id,
name, name,
is_animated,
} }
} }