chore(print/list): get note titles to render

This commit is contained in:
Elian Doran 2025-11-20 20:13:20 +02:00
parent 165357f444
commit 7f81b83955
No known key found for this signature in database
2 changed files with 26 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import { allViewTypes, ViewModeMedia, ViewModeProps, ViewTypeOptions } from "./i
import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useTriliumEvent } from "../react/hooks";
import FNote from "../../entities/fnote";
import "./NoteList.css";
import { ListView, GridView } from "./legacy/ListOrGridView";
import { ListView, GridView, ListPrintView } from "./legacy/ListOrGridView";
import { useEffect, useRef, useState } from "preact/hooks";
import GeoView from "./geomap";
import ViewModeStorage from "./view_mode_storage";
@ -103,7 +103,11 @@ export function CustomNoteList({ note, viewType, isEnabled: shouldEnable, notePa
function getComponentByViewType(viewType: ViewTypeOptions, props: ViewModeProps<any>) {
switch (viewType) {
case "list":
if (props.media !== "print") {
return <ListView {...props} />;
} else {
return <ListPrintView {...props} />;
}
case "grid":
return <GridView {...props} />;
case "geoMap":

View File

@ -11,6 +11,7 @@ import tree from "../../../services/tree";
import link from "../../../services/link";
import { t } from "../../../services/i18n";
import attribute_renderer from "../../../services/attribute_renderer";
import froca from "../../../services/froca";
export function ListView({ note, noteIds: unfilteredNoteIds, highlightedTokens }: ViewModeProps<{}>) {
const [ isExpanded ] = useNoteLabelBoolean(note, "expanded");
@ -34,6 +35,25 @@ export function ListView({ note, noteIds: unfilteredNoteIds, highlightedTokens }
);
}
export function ListPrintView({ note, noteIds: unfilteredNoteIds, highlightedTokens }: ViewModeProps<{}>) {
const noteIds = useFilteredNoteIds(note, unfilteredNoteIds);
const [ notes, setNotes ] = useState<FNote[]>();
useEffect(() => {
froca.getNotes(noteIds).then(setNotes);
}, [noteIds]);
return (
<div class="note-list list-print-view">
<div class="note-list-container use-tn-links">
{notes?.map(childNote => (
<h1>{childNote.title}</h1>
))}
</div>
</div>
);
}
export function GridView({ note, noteIds: unfilteredNoteIds, highlightedTokens }: ViewModeProps<{}>) {
const noteIds = useFilteredNoteIds(note, unfilteredNoteIds);
const { pageNotes, ...pagination } = usePagination(note, noteIds);