diff --git a/apps/client/src/widgets/layout/InlineTitle.tsx b/apps/client/src/widgets/layout/InlineTitle.tsx index f4c176c14..62e1052d6 100644 --- a/apps/client/src/widgets/layout/InlineTitle.tsx +++ b/apps/client/src/widgets/layout/InlineTitle.tsx @@ -7,6 +7,7 @@ import { useEffect, useRef, useState } from "preact/hooks"; import { Trans } from "react-i18next"; import FNote from "../../entities/fnote"; +import { ViewScope } from "../../services/link"; import { formatDateTime } from "../../utils/formatters"; import NoteIcon from "../note_icon"; import NoteTitleWidget from "../note_title"; @@ -19,13 +20,13 @@ const supportedNoteTypes = new Set([ ]); export default function InlineTitle() { - const { note, parentComponent } = useNoteContext(); - const [ shown, setShown ] = useState(shouldShow(note)); + const { note, parentComponent, viewScope } = useNoteContext(); + const [ shown, setShown ] = useState(shouldShow(note, viewScope)); const containerRef= useRef(null); useEffect(() => { - setShown(shouldShow(note)); - }, [ note ]); + setShown(shouldShow(note, viewScope)); + }, [ note, viewScope ]); useEffect(() => { if (!shown) return; @@ -63,25 +64,25 @@ export default function InlineTitle() { ); } -function shouldShow(note: FNote | null | undefined) { +function shouldShow(note: FNote | null | undefined, viewScope: ViewScope | undefined) { if (!note) return false; + if (viewScope?.viewMode !== "default") return false; return supportedNoteTypes.has(note.type); } export function NoteTitleDetails() { - const { note, noteContext } = useNoteContext(); + const { note } = useNoteContext(); const { metadata } = useNoteMetadata(note); const isHiddenNote = note?.noteId.startsWith("_"); - const isDefaultView = noteContext?.viewScope?.viewMode === "default"; const items: ComponentChild[] = [ - (isDefaultView && !isHiddenNote && metadata?.dateCreated && + (!isHiddenNote && metadata?.dateCreated && ), - (isDefaultView && !isHiddenNote && metadata?.dateModified && + (!isHiddenNote && metadata?.dateModified && ) ].filter(item => !!item); - return items.length && ( + return items.length > 0 && (
{joinElements(items, " • ")}