Skip to content

Commit 7f81b83

Browse files
committed
chore(print/list): get note titles to render
1 parent 165357f commit 7f81b83

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

apps/client/src/widgets/collections/NoteList.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { allViewTypes, ViewModeMedia, ViewModeProps, ViewTypeOptions } from "./i
22
import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useTriliumEvent } from "../react/hooks";
33
import FNote from "../../entities/fnote";
44
import "./NoteList.css";
5-
import { ListView, GridView } from "./legacy/ListOrGridView";
5+
import { ListView, GridView, ListPrintView } from "./legacy/ListOrGridView";
66
import { useEffect, useRef, useState } from "preact/hooks";
77
import GeoView from "./geomap";
88
import ViewModeStorage from "./view_mode_storage";
@@ -103,7 +103,11 @@ export function CustomNoteList({ note, viewType, isEnabled: shouldEnable, notePa
103103
function getComponentByViewType(viewType: ViewTypeOptions, props: ViewModeProps<any>) {
104104
switch (viewType) {
105105
case "list":
106-
return <ListView {...props} />;
106+
if (props.media !== "print") {
107+
return <ListView {...props} />;
108+
} else {
109+
return <ListPrintView {...props} />;
110+
}
107111
case "grid":
108112
return <GridView {...props} />;
109113
case "geoMap":

apps/client/src/widgets/collections/legacy/ListOrGridView.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import tree from "../../../services/tree";
1111
import link from "../../../services/link";
1212
import { t } from "../../../services/i18n";
1313
import attribute_renderer from "../../../services/attribute_renderer";
14+
import froca from "../../../services/froca";
1415

1516
export function ListView({ note, noteIds: unfilteredNoteIds, highlightedTokens }: ViewModeProps<{}>) {
1617
const [ isExpanded ] = useNoteLabelBoolean(note, "expanded");
@@ -34,6 +35,25 @@ export function ListView({ note, noteIds: unfilteredNoteIds, highlightedTokens }
3435
);
3536
}
3637

38+
export function ListPrintView({ note, noteIds: unfilteredNoteIds, highlightedTokens }: ViewModeProps<{}>) {
39+
const noteIds = useFilteredNoteIds(note, unfilteredNoteIds);
40+
const [ notes, setNotes ] = useState<FNote[]>();
41+
42+
useEffect(() => {
43+
froca.getNotes(noteIds).then(setNotes);
44+
}, [noteIds]);
45+
46+
return (
47+
<div class="note-list list-print-view">
48+
<div class="note-list-container use-tn-links">
49+
{notes?.map(childNote => (
50+
<h1>{childNote.title}</h1>
51+
))}
52+
</div>
53+
</div>
54+
);
55+
}
56+
3757
export function GridView({ note, noteIds: unfilteredNoteIds, highlightedTokens }: ViewModeProps<{}>) {
3858
const noteIds = useFilteredNoteIds(note, unfilteredNoteIds);
3959
const { pageNotes, ...pagination } = usePagination(note, noteIds);

0 commit comments

Comments
 (0)