This commit is contained in:
2026-07-19 07:37:13 +02:00
parent e998ba8fc7
commit 3344064030
3 changed files with 27 additions and 2 deletions

View File

@@ -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
});
};

View File

@@ -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');

View File

@@ -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
});
};