mirror of
https://github.com/zadam/trilium.git
synced 2025-12-17 21:59:55 +01:00
feat(layout/inline-title): react to template add/remove
This commit is contained in:
@@ -18,7 +18,7 @@ import NoteIcon from "../note_icon";
|
|||||||
import NoteTitleWidget from "../note_title";
|
import NoteTitleWidget from "../note_title";
|
||||||
import { Badge, BadgeWithDropdown } from "../react/Badge";
|
import { Badge, BadgeWithDropdown } from "../react/Badge";
|
||||||
import { FormListItem } from "../react/FormList";
|
import { FormListItem } from "../react/FormList";
|
||||||
import { useNoteBlob, useNoteContext, useNoteProperty, useStaticTooltip } from "../react/hooks";
|
import { useNoteBlob, useNoteContext, useNoteProperty, useStaticTooltip, useTriliumEvent } from "../react/hooks";
|
||||||
import { joinElements } from "../react/react_utils";
|
import { joinElements } from "../react/react_utils";
|
||||||
import { useNoteMetadata } from "../ribbon/NoteInfoTab";
|
import { useNoteMetadata } from "../ribbon/NoteInfoTab";
|
||||||
import { onWheelHorizontalScroll } from "../widget_utils";
|
import { onWheelHorizontalScroll } from "../widget_utils";
|
||||||
@@ -205,9 +205,15 @@ function TemplateNoteTypes({ noteId }: { noteId: string }) {
|
|||||||
setTemplates(templateNotes);
|
setTemplates(templateNotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
// First load.
|
||||||
refreshTemplates();
|
useEffect(() => { refreshTemplates(); }, []);
|
||||||
}, []);
|
|
||||||
|
// React to external changes.
|
||||||
|
useTriliumEvent("entitiesReloaded", ({ loadResults }) => {
|
||||||
|
if (loadResults.getAttributeRows().some(attr => attr.type === "label" && attr.name === "template")) {
|
||||||
|
refreshTemplates();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BadgeWithDropdown
|
<BadgeWithDropdown
|
||||||
|
|||||||
Reference in New Issue
Block a user