summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-21 17:33:46 +0500
committerilotterytea <iltsu@alright.party>2025-04-21 17:33:46 +0500
commit92ea7a326b4430f3dbeb94f150df680e432f5ddf (patch)
tree0fa7d96a4c45837d4c41b5e84b3c7c1aa16286be /public
parent3c97031c879a227018dbdc4189b896a0a8998b06 (diff)
feat: check emote if it has been already added
Diffstat (limited to 'public')
-rw-r--r--public/emotes/index.php24
-rw-r--r--public/static/style.css13
2 files changed, 32 insertions, 5 deletions
diff --git a/public/emotes/index.php b/public/emotes/index.php
index 9421e65..63bc9da 100644
--- a/public/emotes/index.php
+++ b/public/emotes/index.php
@@ -7,11 +7,23 @@ authorize_user();
function display_list_emotes(int $page, int $limit): array
{
+ $user_id = $_SESSION["user_id"] ?? "-1";
$offset = $page * $limit;
$db = new PDO(DB_URL, DB_USER, DB_PASS);
- $stmt = $db->prepare("SELECT * FROM emotes ORDER BY created_at ASC LIMIT ? OFFSET ?");
- $stmt->bindParam(1, $limit, PDO::PARAM_INT);
- $stmt->bindParam(2, $offset, PDO::PARAM_INT);
+ $stmt = $db->prepare("SELECT e.*,
+ CASE WHEN EXISTS (
+ SELECT 1
+ FROM emote_set_contents ec
+ INNER JOIN emote_sets es ON es.id = ec.emote_set_id
+ WHERE ec.emote_id = e.id AND es.owner_id = ?
+ ) THEN 1 ELSE 0 END AS is_in_user_set
+ FROM emotes e
+ ORDER BY e.created_at ASC
+ LIMIT ? OFFSET ?
+ ");
+ $stmt->bindParam(1, $user_id, PDO::PARAM_INT);
+ $stmt->bindParam(2, $limit, PDO::PARAM_INT);
+ $stmt->bindParam(3, $offset, PDO::PARAM_INT);
$stmt->execute();
$emotes = [];
@@ -24,7 +36,8 @@ function display_list_emotes(int $page, int $limit): array
$row["code"],
$row["ext"],
intval(strtotime($row["created_at"])),
- $row["uploaded_by"]
+ $row["uploaded_by"],
+ $row["is_in_user_set"]
));
}
@@ -45,7 +58,8 @@ function display_emote(int $id)
$row["code"],
$row["ext"],
intval(strtotime($row["created_at"])),
- $row["uploaded_by"]
+ $row["uploaded_by"],
+ false
);
}
diff --git a/public/static/style.css b/public/static/style.css
index 933e46e..86013be 100644
--- a/public/static/style.css
+++ b/public/static/style.css
@@ -330,6 +330,19 @@ a.box:hover {
border-color: #9f5050;
}
+.emote-check {
+ position: relative;
+ left: 35px;
+ top: 10px;
+ width: 24px;
+ height: 24px;
+ z-index: 2;
+}
+
+.emote:has(.emote-check) img {
+ margin-top: -15px;
+}
+
/**
-------------
ACCOUNTS