From 334406403061fd6045219094cefbc1eaab276c6b Mon Sep 17 00:00:00 2001 From: Kibi Kelburton Date: Sun, 19 Jul 2026 07:37:13 +0200 Subject: [PATCH] tags --- public/s/js/admin.js | 8 +++++++- public/s/js/f0ckm.js | 13 +++++++++++++ public/s/js/user.js | 8 +++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/public/s/js/admin.js b/public/s/js/admin.js index cde88c1..21c5a5e 100644 --- a/public/s/js/admin.js +++ b/public/s/js/admin.js @@ -155,7 +155,13 @@ postid, existingTags: tags, anchorEl: anchor, - onSubmit: async (tag) => post("/api/v2/tags/" + postid, { tagname: tag }), + onSubmit: async (tag) => { + const res = await post("/api/v2/tags/" + postid, { tagname: tag }); + if (res.success && window.invalidateItemCache) { + window.invalidateItemCache(postid); + } + return res; + }, renderTags }); }; diff --git a/public/s/js/f0ckm.js b/public/s/js/f0ckm.js index 26bcd77..792df98 100644 --- a/public/s/js/f0ckm.js +++ b/public/s/js/f0ckm.js @@ -6973,6 +6973,19 @@ window.cancelAnimFrame = (function () { // Export loaders for external systems (like NotificationSystem) window.loadPageAjax = loadPageAjax; window.loadItemAjax = loadItemAjax; + + // Invalidate all itemCacheMap entries that contain a given item ID. + // Call this after mutating an item (e.g. adding a tag) so the next + // AJAX navigation fetches fresh HTML instead of serving stale cache. + window.invalidateItemCache = (itemId) => { + if (!itemId) return; + const needle = `/${itemId}`; + for (const key of itemCacheMap.keys()) { + if (key.includes(needle)) { + itemCacheMap.delete(key); + } + } + }; // Continued... const sbtForm = document.getElementById('sbtForm'); diff --git a/public/s/js/user.js b/public/s/js/user.js index 377c677..c76e055 100644 --- a/public/s/js/user.js +++ b/public/s/js/user.js @@ -120,7 +120,13 @@ postid, existingTags: tags, anchorEl: anchor, - onSubmit: async (tag) => post("/api/v2/tags/" + postid, { tagname: tag }), + onSubmit: async (tag) => { + const res = await post("/api/v2/tags/" + postid, { tagname: tag }); + if (res.success && window.invalidateItemCache) { + window.invalidateItemCache(postid); + } + return res; + }, renderTags }); };