tags
This commit is contained in:
@@ -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
|
||||
});
|
||||
};
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user