mirror of
https://github.com/zadam/trilium.git
synced 2025-12-16 21:29:56 +01:00
fix(layout/inline-title): hide in attachments and other view scopes
This commit is contained in:
@@ -7,6 +7,7 @@ import { useEffect, useRef, useState } from "preact/hooks";
|
|||||||
import { Trans } from "react-i18next";
|
import { Trans } from "react-i18next";
|
||||||
|
|
||||||
import FNote from "../../entities/fnote";
|
import FNote from "../../entities/fnote";
|
||||||
|
import { ViewScope } from "../../services/link";
|
||||||
import { formatDateTime } from "../../utils/formatters";
|
import { formatDateTime } from "../../utils/formatters";
|
||||||
import NoteIcon from "../note_icon";
|
import NoteIcon from "../note_icon";
|
||||||
import NoteTitleWidget from "../note_title";
|
import NoteTitleWidget from "../note_title";
|
||||||
@@ -19,13 +20,13 @@ const supportedNoteTypes = new Set<NoteType>([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
export default function InlineTitle() {
|
export default function InlineTitle() {
|
||||||
const { note, parentComponent } = useNoteContext();
|
const { note, parentComponent, viewScope } = useNoteContext();
|
||||||
const [ shown, setShown ] = useState(shouldShow(note));
|
const [ shown, setShown ] = useState(shouldShow(note, viewScope));
|
||||||
const containerRef= useRef<HTMLDivElement>(null);
|
const containerRef= useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setShown(shouldShow(note));
|
setShown(shouldShow(note, viewScope));
|
||||||
}, [ note ]);
|
}, [ note, viewScope ]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!shown) return;
|
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 (!note) return false;
|
||||||
|
if (viewScope?.viewMode !== "default") return false;
|
||||||
return supportedNoteTypes.has(note.type);
|
return supportedNoteTypes.has(note.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NoteTitleDetails() {
|
export function NoteTitleDetails() {
|
||||||
const { note, noteContext } = useNoteContext();
|
const { note } = useNoteContext();
|
||||||
const { metadata } = useNoteMetadata(note);
|
const { metadata } = useNoteMetadata(note);
|
||||||
const isHiddenNote = note?.noteId.startsWith("_");
|
const isHiddenNote = note?.noteId.startsWith("_");
|
||||||
const isDefaultView = noteContext?.viewScope?.viewMode === "default";
|
|
||||||
|
|
||||||
const items: ComponentChild[] = [
|
const items: ComponentChild[] = [
|
||||||
(isDefaultView && !isHiddenNote && metadata?.dateCreated &&
|
(!isHiddenNote && metadata?.dateCreated &&
|
||||||
<TextWithValue
|
<TextWithValue
|
||||||
i18nKey="note_title.created_on"
|
i18nKey="note_title.created_on"
|
||||||
value={formatDateTime(metadata.dateCreated, "medium", "none")}
|
value={formatDateTime(metadata.dateCreated, "medium", "none")}
|
||||||
valueTooltip={formatDateTime(metadata.dateCreated, "full", "long")}
|
valueTooltip={formatDateTime(metadata.dateCreated, "full", "long")}
|
||||||
/>),
|
/>),
|
||||||
(isDefaultView && !isHiddenNote && metadata?.dateModified &&
|
(!isHiddenNote && metadata?.dateModified &&
|
||||||
<TextWithValue
|
<TextWithValue
|
||||||
i18nKey="note_title.last_modified"
|
i18nKey="note_title.last_modified"
|
||||||
value={formatDateTime(metadata.dateModified, "medium", "none")}
|
value={formatDateTime(metadata.dateModified, "medium", "none")}
|
||||||
@@ -89,7 +90,7 @@ export function NoteTitleDetails() {
|
|||||||
/>)
|
/>)
|
||||||
].filter(item => !!item);
|
].filter(item => !!item);
|
||||||
|
|
||||||
return items.length && (
|
return items.length > 0 && (
|
||||||
<div className="title-details">
|
<div className="title-details">
|
||||||
{joinElements(items, " • ")}
|
{joinElements(items, " • ")}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user