From 4a4502dfea60d36cfce0eac52d3c2a66b96aefb0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 20 Sep 2025 11:55:43 +0300 Subject: [PATCH] chore(react/type_widget): bring back read-only temporary disable --- apps/client/src/widgets/NoteDetail.tsx | 10 ++++++++-- apps/client/src/widgets/type_widgets/code/Code.tsx | 1 - .../client/src/widgets/type_widgets_old/type_widget.ts | 8 -------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsx index 0ae5c15d2..e3bba09a3 100644 --- a/apps/client/src/widgets/NoteDetail.tsx +++ b/apps/client/src/widgets/NoteDetail.tsx @@ -65,12 +65,18 @@ function useNoteInfo() { const [ note, setNote ] = useState(); const [ type, setType ] = useState(); - useEffect(() => { + function refresh() { getWidgetType(actualNote, noteContext).then(type => { setNote(actualNote); setType(type); }); - }, [ actualNote, noteContext ]); + } + + useEffect(refresh, [ actualNote, noteContext]); + useTriliumEvent("readOnlyTemporarilyDisabled", ({ noteContext: eventNoteContext }) => { + if (eventNoteContext?.ntxId !== noteContext?.ntxId) return; + refresh(); + }); return { note, type, noteContext, parentComponent }; } diff --git a/apps/client/src/widgets/type_widgets/code/Code.tsx b/apps/client/src/widgets/type_widgets/code/Code.tsx index 0c9bb1559..85c71c6bc 100644 --- a/apps/client/src/widgets/type_widgets/code/Code.tsx +++ b/apps/client/src/widgets/type_widgets/code/Code.tsx @@ -139,7 +139,6 @@ function CodeEditor({ note, parentComponent, ntxId, containerRef: externalContai }); useTriliumEvent("focusOnDetail", ({ ntxId: eventNtxId }) => { - console.log("Focus on ", ntxId, eventNtxId) if (eventNtxId !== ntxId) return; codeEditorRef.current?.focus(); }); diff --git a/apps/client/src/widgets/type_widgets_old/type_widget.ts b/apps/client/src/widgets/type_widgets_old/type_widget.ts index a5e66221e..47dec1df1 100644 --- a/apps/client/src/widgets/type_widgets_old/type_widget.ts +++ b/apps/client/src/widgets/type_widgets_old/type_widget.ts @@ -61,14 +61,6 @@ export default abstract class TypeWidget extends NoteContextAwareWidget { // Do nothing by default. } - async readOnlyTemporarilyDisabledEvent({ noteContext }: EventData<"readOnlyTemporarilyDisabled">) { - if (this.isNoteContext(noteContext.ntxId)) { - await this.refresh(); - - this.focus(); - } - } - /** * {@inheritdoc} *