From 805c97b8e4228d6d6c9b9a65f6716398d076c8cc Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Wed, 15 Jul 2026 23:28:56 +0200 Subject: [PATCH] tg stickers v5.1 --- public/s/js/sidebar-activity.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/public/s/js/sidebar-activity.js b/public/s/js/sidebar-activity.js index 3a7ef33..67c84d4 100644 --- a/public/s/js/sidebar-activity.js +++ b/public/s/js/sidebar-activity.js @@ -9,6 +9,14 @@ if (!window._sidebarActivityCache) window._sidebarActivityCache = []; const loadEmojis = async () => { + // Prefer CommentSystem's already-fetched cache to avoid a redundant request + const csCache = (typeof CommentSystem !== 'undefined' && CommentSystem.emojiCache) + || null; + if (csCache && Object.keys(csCache).length > 0) { + Object.assign(customEmojis, csCache); + return; + } + // No shared cache yet — fetch directly if (Object.keys(customEmojis).length > 0) return; try { const res = await fetch('/api/v2/emojis'); @@ -859,6 +867,20 @@ handleLiveEdit(e.detail); }); + // When emojis are refreshed (e.g. after sticker pack import), sync the sidebar + // cache and re-render so newly imported stickers appear in existing entries. + window.addEventListener('f0ck:emojis_ready', () => { + const csCache = (typeof CommentSystem !== 'undefined' && CommentSystem.emojiCache) || null; + if (!csCache || Object.keys(csCache).length === 0) return; + // Merge new emojis into local cache (additive — never removes) + const hadBefore = Object.keys(customEmojis).length; + Object.assign(customEmojis, csCache); + const hasNew = Object.keys(customEmojis).length > hadBefore; + if (hasNew && window._sidebarActivityCache.length > 0) { + renderFromCache(); + } + }); + let lastBoundMode = typeof window.activeMode !== 'undefined' ? window.activeMode : null; // Handle AJAX item loads