Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/content manager: fix an issue
Adorian Doran6c8865080ec8
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager.tsx b/apps/client/src/widgets/type_widgets/options/content_manager.tsxindex 306dfe7ac1..5d56c11742 100644--- a/apps/client/src/widgets/type_widgets/options/content_manager.tsx+++ b/apps/client/src/widgets/type_widgets/options/content_manager.tsx@@ -5,6 +5,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks"import appContext from "../../../components/app_context";import type FNote from "../../../entities/fnote";+import attributeService from "../../../services/attributes";import branches from "../../../services/branches";import {buildLocationTree,@@ -144,9 +145,18 @@ function ContentProperties({ note, category }: { note: FNote, category: ContentCfunction ContentToggle({ note, category }: { note: FNote, category: ContentCategory }) {const [ enabled, setEnabled ] = useState(() => isCategoryEnabled(note, category));- // Re-sync when the row is reused for another note, or the state changed elsewhere.+ // Re-sync when the row is reused for another note.useEffect(() => setEnabled(isCategoryEnabled(note, category)), [ note, category ]);+ // ...and when the attributes change under it. The switch holds its own optimistic state, so+ // without this it goes stale on any change it did not make itself — another row, the attribute+ // bar, or a sync.+ useTriliumEvent("entitiesReloaded", ({ loadResults }) => {+ if (loadResults.getAttributeRows().some((attribute) => attributeService.isAffecting(attribute, note))) {+ setEnabled(isCategoryEnabled(note, category));+ }+ });+return (<FormToggleswitchOnName="" switchOffName=""