mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
fix(client): note title not working for in-app help
This commit is contained in:
parent
fbd47025d6
commit
57004ab848
@ -11,14 +11,14 @@ import branches from "../services/branches";
|
||||
import { isIMEComposing } from "../services/shortcuts";
|
||||
|
||||
export default function NoteTitleWidget() {
|
||||
const { note, noteId, componentId, viewScope, noteContext, parentComponent } = useNoteContext();
|
||||
const title = useNoteProperty(note, "title", componentId);
|
||||
const { note, noteId, componentId, viewScope, noteContext, parentComponent } = useNoteContext();
|
||||
const title = useNoteProperty(note, "title", componentId);
|
||||
const isProtected = useNoteProperty(note, "isProtected");
|
||||
const newTitle = useRef("");
|
||||
|
||||
|
||||
const [ isReadOnly, setReadOnly ] = useState<boolean>(false);
|
||||
const [ navigationTitle, setNavigationTitle ] = useState<string | null>(null);
|
||||
|
||||
const [ navigationTitle, setNavigationTitle ] = useState<string | null>(null);
|
||||
|
||||
// Manage read-only
|
||||
useEffect(() => {
|
||||
const isReadOnly = note === null
|
||||
@ -34,7 +34,7 @@ export default function NoteTitleWidget() {
|
||||
if (isReadOnly) {
|
||||
noteContext?.getNavigationTitle().then(setNavigationTitle);
|
||||
}
|
||||
}, [isReadOnly]);
|
||||
}, [noteContext, isReadOnly]);
|
||||
|
||||
// Save changes to title.
|
||||
const spacedUpdate = useSpacedUpdate(async () => {
|
||||
@ -43,11 +43,11 @@ export default function NoteTitleWidget() {
|
||||
}
|
||||
protected_session_holder.touchProtectedSessionIfNecessary(note);
|
||||
await server.put<void>(`notes/${noteId}/title`, { title: newTitle.current }, componentId);
|
||||
});
|
||||
});
|
||||
|
||||
// Prevent user from navigating away if the spaced update is not done.
|
||||
useEffect(() => {
|
||||
appContext.addBeforeUnloadListener(() => spacedUpdate.isAllSavedAndTriggerUpdate());
|
||||
appContext.addBeforeUnloadListener(() => spacedUpdate.isAllSavedAndTriggerUpdate());
|
||||
}, []);
|
||||
useTriliumEvents([ "beforeNoteSwitch", "beforeNoteContextRemove" ], () => spacedUpdate.updateNowIfNecessary());
|
||||
|
||||
@ -84,7 +84,7 @@ export default function NoteTitleWidget() {
|
||||
if (isIMEComposing(e)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Focus on the note content when pressing enter.
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
|
Loading…
x
Reference in New Issue
Block a user