fix: invalidate cron skill picker cache on form open and after skill save (#502)
Two complementary cache-busting strategies for the stale cron skill picker: 1. On cron form open (toggleCronForm): always null _cronSkillsCache before fetching, so freshly created skills are immediately visible without a page reload. Previously the cache was only populated once and never invalidated. 2. On skill save (submitSkillSave): null _cronSkillsCache after a successful write so the next cron form open is forced to re-fetch. Mirrors the existing _skillsData=null pattern one line above. Fixes: #502 Co-authored-by: armorbreak001 <armorbreak001@users.noreply.github.com>
This commit is contained in:
@@ -97,10 +97,9 @@ function toggleCronForm(){
|
||||
_renderCronSkillTags();
|
||||
const search=$('cronFormSkillSearch');
|
||||
if(search)search.value='';
|
||||
// Pre-fetch skills for the picker
|
||||
if(!_cronSkillsCache){
|
||||
api('/api/skills').then(d=>{_cronSkillsCache=d.skills||[];}).catch(()=>{});
|
||||
}
|
||||
// Always re-fetch skills to avoid stale cache
|
||||
_cronSkillsCache=null;
|
||||
api('/api/skills').then(d=>{_cronSkillsCache=d.skills||[];}).catch(()=>{});
|
||||
$('cronFormName').focus();
|
||||
}
|
||||
}
|
||||
@@ -485,6 +484,7 @@ async function submitSkillSave() {
|
||||
await api('/api/skills/save', {method:'POST', body: JSON.stringify({name, category: category||undefined, content})});
|
||||
showToast(_editingSkillName ? t('skill_updated') : t('skill_created'));
|
||||
_skillsData = null;
|
||||
_cronSkillsCache = null;
|
||||
toggleSkillForm();
|
||||
await loadSkills();
|
||||
} catch(e) { errEl.textContent = t('error_prefix') + e.message; errEl.style.display = ''; }
|
||||
|
||||
Reference in New Issue
Block a user