diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx index 346697ff5..0eb5e8e46 100644 --- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx +++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx @@ -101,7 +101,7 @@ function ToggleReadOnlyButton({ note, viewType, isDefaultViewMode }: FloatingBut function EditButton({ note, noteContext, isDefaultViewMode }: FloatingButtonContext) { const [animationClass, setAnimationClass] = useState(""); - const {isReadOnly, enableEditing} = useIsNoteReadOnly(); + const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext); // make the edit button stand out on the first display, otherwise // it's difficult to notice that the note is readonly diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index b28f642cf..a7a17505c 100644 --- a/apps/client/src/widgets/react/hooks.tsx +++ b/apps/client/src/widgets/react/hooks.tsx @@ -707,9 +707,8 @@ export function useResizeObserver(ref: RefObject, callback: () => v * Indicates that the current note is in read-only mode, while an editing mode is available, * and provides a way to switch to editing mode. */ -export function useIsNoteReadOnly() { - const {note, noteContext} = useNoteContext(); - const [isReadOnly, setIsReadOnly] = useState(false); +export function useIsNoteReadOnly(note: FNote | null | undefined, noteContext: NoteContext | undefined) { + const [isReadOnly, setIsReadOnly] = useState(undefined); const enableEditing = useCallback(() => { if (noteContext?.viewScope) { diff --git a/apps/client/src/widgets/read_only_note_info_bar.tsx b/apps/client/src/widgets/read_only_note_info_bar.tsx index f181687db..c7dcba9c9 100644 --- a/apps/client/src/widgets/read_only_note_info_bar.tsx +++ b/apps/client/src/widgets/read_only_note_info_bar.tsx @@ -4,8 +4,8 @@ import { useIsNoteReadOnly, useNoteContext, useTriliumEvent } from "./react/hook import Button from "./react/Button"; export default function ReadOnlyNoteInfoBar(props: {zenModeOnly?: boolean}) { - const {isReadOnly, enableEditing} = useIsNoteReadOnly(); - const {note} = useNoteContext(); + const {note, noteContext} = useNoteContext(); + const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext); return
{isReadOnly && <>