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
feat(note_map): allow bypassing the limit (closes #9593)
Elian Doran00376e82a029
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 16efb4ae0b..039310f8fa 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -926,7 +926,8 @@"title": "Note Map","fix-nodes": "Fix nodes","link-distance": "Link distance",- "too-many-notes": "This subtree contains {{count}} notes, which exceeds the limit of {{max}} that can be displayed in the note map."+ "too-many-notes": "There are {{count}} notes here. Showing them all may slow things down.",+ "show-anyway": "Show map"},"note_paths": {"title": "Note Paths",diff --git a/apps/client/src/widgets/note_map/NoteMap.tsx b/apps/client/src/widgets/note_map/NoteMap.tsxindex a165d467bb..acdee57b9f 100644--- a/apps/client/src/widgets/note_map/NoteMap.tsx+++ b/apps/client/src/widgets/note_map/NoteMap.tsx@@ -11,6 +11,7 @@ import hoisted_note from "../../services/hoisted_note";import { t } from "../../services/i18n";import { getEffectiveThemeStyle } from "../../services/theme";import ActionButton from "../react/ActionButton";+import Button from "../react/Button";import { useElementSize, useNoteLabel } from "../react/hooks";import NoItems from "../react/NoItems";import Slider from "../react/Slider";@@ -39,6 +40,7 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) {const [ fixNodes, setFixNodes ] = useState(false);const [ linkDistance, setLinkDistance ] = useState(40);const [ tooManyNotes, setTooManyNotes ] = useState<number | null>(null);+ const [ bypassLimit, setBypassLimit ] = useState(false);const notesAndRelationsRef = useRef<NotesAndRelationsData>();const mapRootId = useMemo(() => {@@ -68,7 +70,7 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) {if (!containerRef.current || !styleResolverRef.current) return;// Guard against rendering too many notes which would freeze the browser.- if (notesAndRelations.nodes.length > MAX_NOTES_THRESHOLD) {+ if (notesAndRelations.nodes.length > MAX_NOTES_THRESHOLD && !bypassLimit) {setTooManyNotes(notesAndRelations.nodes.length);return;}@@ -105,7 +107,7 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) {});return () => container.replaceChildren();- }, [ note, mapType ]);+ }, [ note, mapType, bypassLimit ]);useEffect(() => {if (!graphRef.current || !notesAndRelationsRef.current) return;@@ -132,9 +134,23 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) {});}, [ fixNodes, mapType ]);- if (tooManyNotes) {+ useEffect(() => {+ setBypassLimit(false);+ }, [ note, mapType ]);++ if (tooManyNotes && !bypassLimit) {return (- <NoItems icon="bx bx-error-circle" text={t("note_map.too-many-notes", { count: tooManyNotes, max: MAX_NOTES_THRESHOLD })} />+ <NoItems+ icon="bx bxs-network-chart"+ text={t("note_map.too-many-notes", { count: tooManyNotes })}+ >+ <Button+ text={t("note_map.show-anyway")}+ kind="primary"+ size="small"+ onClick={() => setBypassLimit(true)}+ />+ </NoItems>);}