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