Skip to content

Build your personal knowledge base with Trilium Notes

fix(ribbon): not refreshing if note is temporarily edited

Elian Doran6f245ec8d585
diff --git a/apps/client/src/components/root_command_executor.ts b/apps/client/src/components/root_command_executor.ts
index 3ad05b7a2a..a2d62edddd 100644
--- a/apps/client/src/components/root_command_executor.ts
+++ b/apps/client/src/components/root_command_executor.ts
@@ -7,7 +7,6 @@ import protectedSessionService from "../services/protected_session.js";
import options from "../services/options.js";
import froca from "../services/froca.js";
import utils from "../services/utils.js";
-import LlmChatPanel from "../widgets/llm_chat_panel.js";
import toastService from "../services/toast.js";
import noteCreateService from "../services/note_create.js";
diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx
index a7a17505ce..9978a003e7 100644
--- a/apps/client/src/widgets/react/hooks.tsx
+++ b/apps/client/src/widgets/react/hooks.tsx
@@ -199,6 +199,7 @@ export function useNoteContext() {
const [ notePath, setNotePath ] = useState<string | null | undefined>();
const [ note, setNote ] = useState<FNote | null | undefined>();
const [ , setViewMode ] = useState<ViewMode>();
+ const [ isReadOnlyTemporarilyDisabled, setIsReadOnlyTemporarilyDisabled ] = useState<boolean | null | undefined>(noteContext?.viewScope?.isReadOnly);
const [ refreshCounter, setRefreshCounter ] = useState(0);
useEffect(() => {
@@ -218,6 +219,11 @@ export function useNoteContext() {
setRefreshCounter(refreshCounter + 1);
}
});
+ useTriliumEvent("readOnlyTemporarilyDisabled", ({ noteContext: eventNoteContext }) => {
+ if (eventNoteContext.ntxId === noteContext?.ntxId) {
+ setIsReadOnlyTemporarilyDisabled(eventNoteContext?.viewScope?.readOnlyTemporarilyDisabled);
+ }
+ });
const parentComponent = useContext(ParentComponent) as ReactWrappedWidget;
useDebugValue(() => `notePath=${notePath}, ntxId=${noteContext?.ntxId}`);
@@ -231,7 +237,8 @@ export function useNoteContext() {
viewScope: noteContext?.viewScope,
componentId: parentComponent.componentId,
noteContext,
- parentComponent
+ parentComponent,
+ isReadOnlyTemporarilyDisabled
};
}
@@ -749,4 +756,4 @@ async function isNoteReadOnly(note: FNote, noteContext: NoteContext) {
}
return true;
-}
\ No newline at end of file
+}
diff --git a/apps/client/src/widgets/ribbon/Ribbon.tsx b/apps/client/src/widgets/ribbon/Ribbon.tsx
index f14e033673..c3e8089bf6 100644
--- a/apps/client/src/widgets/ribbon/Ribbon.tsx
+++ b/apps/client/src/widgets/ribbon/Ribbon.tsx
@@ -16,7 +16,7 @@ interface ComputedTab extends Indexed<TabConfiguration> {
}
export default function Ribbon() {
- const { note, ntxId, hoistedNoteId, notePath, noteContext, componentId } = useNoteContext();
+ const { note, ntxId, hoistedNoteId, notePath, noteContext, componentId, isReadOnlyTemporarilyDisabled } = useNoteContext();
const noteType = useNoteProperty(note, "type");
const [ activeTabIndex, setActiveTabIndex ] = useState<number | undefined>();
const [ computedTabs, setComputedTabs ] = useState<ComputedTab[]>();
@@ -39,7 +39,7 @@ export default function Ribbon() {
useEffect(() => {
refresh();
- }, [ note, noteType ]);
+ }, [ note, noteType, isReadOnlyTemporarilyDisabled ]);
// Automatically activate the first ribbon tab that needs to be activated whenever a note changes.
useEffect(() => {