feat(text-snippets): reload when a new template is added

This commit is contained in:
Elian Doran 2025-06-17 17:13:11 +03:00
parent 97799bfacc
commit 3e40a35c19
No known key found for this signature in database

View File

@ -36,6 +36,11 @@ export default async function getTemplates() {
return definitions; return definitions;
} }
function handleFullReload() {
console.warn("Full text editor reload needed");
appContext.triggerCommand("reloadTextEditor");
}
async function handleContentUpdate(affectedNoteIds: string[]) { async function handleContentUpdate(affectedNoteIds: string[]) {
const updatedNoteIds = new Set(affectedNoteIds); const updatedNoteIds = new Set(affectedNoteIds);
const templateNoteIds = new Set(templateCache.keys()); const templateNoteIds = new Set(templateCache.keys());
@ -66,8 +71,7 @@ async function handleContentUpdate(affectedNoteIds: string[]) {
} }
if (fullReloadNeeded) { if (fullReloadNeeded) {
console.warn("Full text editor reload needed"); handleFullReload();
appContext.triggerCommand("reloadTextEditor");
} }
} }
@ -77,6 +81,11 @@ export function updateTemplateCache(loadResults: LoadResults): boolean {
debouncedHandleContentUpdate(affectedNoteIds); debouncedHandleContentUpdate(affectedNoteIds);
} }
if (loadResults.getAttributeRows().find((attr) =>
attr.type === "label" &&
attr.name === "textSnippet")) {
handleFullReload();
}
return false; return false;
} }