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
chore(right_pane): address requested changes
Elian Doran1e885625f610
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsxindex 034e77daba..10a5983c6e 100644--- a/apps/client/src/widgets/react/hooks.tsx+++ b/apps/client/src/widgets/react/hooks.tsx@@ -22,7 +22,8 @@ import shortcuts, { Handler, removeIndividualBinding } from "../../services/shorimport SpacedUpdate from "../../services/spaced_update";import toast, { ToastOptions } from "../../services/toast";import tree from "../../services/tree";-import utils, { escapeRegExp, randomString, reloadFrontendApp } from "../../services/utils";+import utils, { escapeRegExp, getErrorMessage, randomString, reloadFrontendApp } from "../../services/utils";+import ws from "../../services/ws";import BasicWidget, { ReactWrappedWidget } from "../basic_widget";import NoteContextAwareWidget from "../note_context_aware_widget";import { DragData } from "../note_tree";@@ -168,14 +169,20 @@ export function useTriliumOption(name: OptionNames, needsRefresh?: boolean): [stconst wrappedSetValue = useMemo(() => {return async (newValue: OptionValue) => {+ const originalValue = value;setValue(String(newValue));- await options.save(name, newValue);+ try {+ await options.save(name, newValue);+ } catch (e: unknown) {+ ws.logError(getErrorMessage(e));+ setValue(originalValue);+ }if (needsRefresh) {reloadFrontendApp(`option change: ${name}`);}};- }, [ name, needsRefresh ]);+ }, [ name, needsRefresh, value ]);useTriliumEvent("entitiesReloaded", useCallback(({ loadResults }) => {if (loadResults.getOptionNames().includes(name)) {diff --git a/apps/client/src/widgets/sidebar/HighlightsList.tsx b/apps/client/src/widgets/sidebar/HighlightsList.tsxindex 0eaeb40dc4..66249f3290 100644--- a/apps/client/src/widgets/sidebar/HighlightsList.tsx+++ b/apps/client/src/widgets/sidebar/HighlightsList.tsx@@ -222,7 +222,7 @@ interface DomHighlight extends RawHighlight {function ReadOnlyTextHighlightsList() {const { noteContext } = useActiveNoteContext();const contentEl = useContentElement(noteContext);- const highlights = extractHeadingsFromStaticHtml(contentEl);+ const highlights = extractHighlightsFromStaticHtml(contentEl);const scrollToHighlight = useCallback((highlight: DomHighlight) => {highlight.element.scrollIntoView();@@ -234,7 +234,7 @@ function ReadOnlyTextHighlightsList() {/>;}-function extractHeadingsFromStaticHtml(el: HTMLElement | null) {+function extractHighlightsFromStaticHtml(el: HTMLElement | null) {if (!el) return [];const { color: defaultColor, backgroundColor: defaultBackgroundColor } = getComputedStyle(el);diff --git a/apps/client/src/widgets/sidebar/RightPanelWidget.tsx b/apps/client/src/widgets/sidebar/RightPanelWidget.tsxindex 4cb8aedf30..099a370899 100644--- a/apps/client/src/widgets/sidebar/RightPanelWidget.tsx+++ b/apps/client/src/widgets/sidebar/RightPanelWidget.tsx@@ -5,7 +5,6 @@ import { useContext, useState } from "preact/hooks";import contextMenu, { MenuItem } from "../../menus/context_menu";import ActionButton from "../react/ActionButton";import { useSyncedRef, useTriliumOptionJson } from "../react/hooks";-import Icon from "../react/Icon";import { ParentComponent } from "../react/react_utils";interface RightPanelWidgetProps {@@ -47,9 +46,7 @@ export default function RightPanelWidget({ id, title, buttons, children, contain} else {rightPaneCollapsedItemsSet.add(id);}- if (rightPaneCollapsedItemsSet.size !== rightPaneCollapsedItems.length) {- setRightPaneCollapsedItems(Array.from(rightPaneCollapsedItemsSet));- }+ setRightPaneCollapsedItems(Array.from(rightPaneCollapsedItemsSet));}}><ActionButton icon="bx bx-chevron-down" text="" />