mirror of
https://github.com/zadam/trilium.git
synced 2025-12-17 12:54:24 +01:00
feat(layout/inline-title): not reacting to note type changes
This commit is contained in:
parent
9946d8c6b9
commit
a2b007874b
@ -25,12 +25,13 @@ const supportedNoteTypes = new Set<NoteType>([
|
|||||||
|
|
||||||
export default function InlineTitle() {
|
export default function InlineTitle() {
|
||||||
const { note, parentComponent, viewScope } = useNoteContext();
|
const { note, parentComponent, viewScope } = useNoteContext();
|
||||||
const [ shown, setShown ] = useState(shouldShow(note, viewScope));
|
const type = useNoteProperty(note, "type");
|
||||||
|
const [ shown, setShown ] = useState(shouldShow(note?.noteId, type, viewScope));
|
||||||
const containerRef= useRef<HTMLDivElement>(null);
|
const containerRef= useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setShown(shouldShow(note, viewScope));
|
setShown(shouldShow(note?.noteId, type, viewScope));
|
||||||
}, [ note, viewScope ]);
|
}, [ note, type, viewScope ]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!shown) return;
|
if (!shown) return;
|
||||||
@ -69,11 +70,10 @@ export default function InlineTitle() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldShow(note: FNote | null | undefined, viewScope: ViewScope | undefined) {
|
function shouldShow(noteId: string | undefined, type: NoteType | undefined, viewScope: ViewScope | undefined) {
|
||||||
if (!note) return false;
|
|
||||||
if (viewScope?.viewMode !== "default") return false;
|
if (viewScope?.viewMode !== "default") return false;
|
||||||
if (note.noteId.startsWith("_options")) return true;
|
if (noteId?.startsWith("_options")) return true;
|
||||||
return supportedNoteTypes.has(note.type);
|
return type && supportedNoteTypes.has(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
//#region Title details
|
//#region Title details
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user