mirror of
https://github.com/zadam/trilium.git
synced 2025-12-03 22:14:24 +01:00
fix(print): fails if included note could not be found
This commit is contained in:
parent
9d0499a306
commit
e0dc25ad23
@ -240,7 +240,7 @@ export default class FNote {
|
|||||||
|
|
||||||
const aNote = this.froca.getNoteFromCache(aNoteId);
|
const aNote = this.froca.getNoteFromCache(aNoteId);
|
||||||
|
|
||||||
if (aNote.isArchived || aNote.isHiddenCompletely()) {
|
if (!aNote || aNote.isArchived || aNote.isHiddenCompletely()) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -56,9 +56,14 @@ async function renderIncludedNotes(contentEl: HTMLElement) {
|
|||||||
// Render and integrate the notes.
|
// Render and integrate the notes.
|
||||||
for (const includeNoteEl of includeNoteEls) {
|
for (const includeNoteEl of includeNoteEls) {
|
||||||
const noteId = includeNoteEl.getAttribute("data-note-id");
|
const noteId = includeNoteEl.getAttribute("data-note-id");
|
||||||
if (!noteId) return;
|
if (!noteId) continue;
|
||||||
|
|
||||||
const note = froca.getNoteFromCache(noteId);
|
const note = froca.getNoteFromCache(noteId);
|
||||||
|
if (!note) {
|
||||||
|
console.warn(`Unable to include ${noteId} because it could not be found.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const renderedContent = (await content_renderer.getRenderedContent(note)).$renderedContent;
|
const renderedContent = (await content_renderer.getRenderedContent(note)).$renderedContent;
|
||||||
includeNoteEl.replaceChildren(...renderedContent);
|
includeNoteEl.replaceChildren(...renderedContent);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ export interface Froca {
|
|||||||
|
|
||||||
getBlob(entityType: string, entityId: string): Promise<FBlob | null>;
|
getBlob(entityType: string, entityId: string): Promise<FBlob | null>;
|
||||||
getNote(noteId: string, silentNotFoundError?: boolean): Promise<FNote | null>;
|
getNote(noteId: string, silentNotFoundError?: boolean): Promise<FNote | null>;
|
||||||
getNoteFromCache(noteId: string): FNote;
|
getNoteFromCache(noteId: string): FNote | undefined;
|
||||||
getNotesFromCache(noteIds: string[], silentNotFoundError?: boolean): FNote[];
|
getNotesFromCache(noteIds: string[], silentNotFoundError?: boolean): FNote[];
|
||||||
getNotes(noteIds: string[], silentNotFoundError?: boolean): Promise<FNote[]>;
|
getNotes(noteIds: string[], silentNotFoundError?: boolean): Promise<FNote[]>;
|
||||||
|
|
||||||
|
|||||||
@ -288,7 +288,7 @@ class FrocaImpl implements Froca {
|
|||||||
return (await this.getNotes([noteId], silentNotFoundError))[0];
|
return (await this.getNotes([noteId], silentNotFoundError))[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
getNoteFromCache(noteId: string) {
|
getNoteFromCache(noteId: string): FNote | undefined {
|
||||||
if (!noteId) {
|
if (!noteId) {
|
||||||
throw new Error("Empty noteId");
|
throw new Error("Empty noteId");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,7 +103,7 @@ export default function BranchPrefixDialog() {
|
|||||||
<input class="branch-prefix-input form-control" value={prefix} ref={branchInput}
|
<input class="branch-prefix-input form-control" value={prefix} ref={branchInput}
|
||||||
onChange={(e) => setPrefix((e.target as HTMLInputElement).value)} />
|
onChange={(e) => setPrefix((e.target as HTMLInputElement).value)} />
|
||||||
{isSingleBranch && branches[0] && (
|
{isSingleBranch && branches[0] && (
|
||||||
<div class="branch-prefix-note-title input-group-text"> - {branches[0].getNoteFromCache().title}</div>
|
<div class="branch-prefix-note-title input-group-text"> - {branches[0].getNoteFromCache()?.title}</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
@ -113,7 +113,7 @@ export default function BranchPrefixDialog() {
|
|||||||
<ul>
|
<ul>
|
||||||
{branches.map((branch) => {
|
{branches.map((branch) => {
|
||||||
const note = branch.getNoteFromCache();
|
const note = branch.getNoteFromCache();
|
||||||
return (
|
return note && (
|
||||||
<li key={branch.branchId}>
|
<li key={branch.branchId}>
|
||||||
{branch.prefix && <span className="branch-prefix-current">{branch.prefix} - </span>}
|
{branch.prefix && <span className="branch-prefix-current">{branch.prefix} - </span>}
|
||||||
{note.title}
|
{note.title}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export default function RecentChangesDialog() {
|
|||||||
const [ refreshCounter, setRefreshCounter ] = useState(0);
|
const [ refreshCounter, setRefreshCounter ] = useState(0);
|
||||||
const [ shown, setShown ] = useState(false);
|
const [ shown, setShown ] = useState(false);
|
||||||
|
|
||||||
useTriliumEvent("showRecentChanges", ({ ancestorNoteId }) => {
|
useTriliumEvent("showRecentChanges", ({ ancestorNoteId }) => {
|
||||||
setAncestorNoteId(ancestorNoteId ?? hoisted_note.getHoistedNoteId());
|
setAncestorNoteId(ancestorNoteId ?? hoisted_note.getHoistedNoteId());
|
||||||
setShown(true);
|
setShown(true);
|
||||||
});
|
});
|
||||||
@ -91,7 +91,7 @@ function RecentChangesTimeline({ groupedByDate, setShown }: { groupedByDate: Map
|
|||||||
return (
|
return (
|
||||||
<li className={isDeleted ? "deleted-note" : ""}>
|
<li className={isDeleted ? "deleted-note" : ""}>
|
||||||
<span title={change.date}>{formattedTime}</span>
|
<span title={change.date}>{formattedTime}</span>
|
||||||
{ !isDeleted
|
{ notePath && !isDeleted
|
||||||
? <NoteLink notePath={notePath} title={change.current_title} />
|
? <NoteLink notePath={notePath} title={change.current_title} />
|
||||||
: <DeletedNoteLink change={change} setShown={setShown} /> }
|
: <DeletedNoteLink change={change} setShown={setShown} /> }
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@ -574,6 +574,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
.loadSearchNote(noteId)
|
.loadSearchNote(noteId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const note = froca.getNoteFromCache(noteId);
|
const note = froca.getNoteFromCache(noteId);
|
||||||
|
if (!note) return [];
|
||||||
|
|
||||||
let childNoteIds = note.getChildNoteIds();
|
let childNoteIds = note.getChildNoteIds();
|
||||||
|
|
||||||
@ -585,6 +586,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const note = froca.getNoteFromCache(noteId);
|
const note = froca.getNoteFromCache(noteId);
|
||||||
|
if (!note) return [];
|
||||||
|
|
||||||
return this.prepareChildren(note);
|
return this.prepareChildren(note);
|
||||||
});
|
});
|
||||||
@ -740,7 +742,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
const node = $.ui.fancytree.getNode(e as unknown as Event);
|
const node = $.ui.fancytree.getNode(e as unknown as Event);
|
||||||
const note = froca.getNoteFromCache(node.data.noteId);
|
const note = froca.getNoteFromCache(node.data.noteId);
|
||||||
|
|
||||||
if (note.isLaunchBarConfig()) {
|
if (note?.isLaunchBarConfig()) {
|
||||||
import("../menus/launcher_context_menu.js").then(({ default: LauncherContextMenu }) => {
|
import("../menus/launcher_context_menu.js").then(({ default: LauncherContextMenu }) => {
|
||||||
const launcherContextMenu = new LauncherContextMenu(this, node);
|
const launcherContextMenu = new LauncherContextMenu(this, node);
|
||||||
launcherContextMenu.show(e);
|
launcherContextMenu.show(e);
|
||||||
@ -775,7 +777,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
if (hideArchivedNotes) {
|
if (hideArchivedNotes) {
|
||||||
const note = branch.getNoteFromCache();
|
const note = branch.getNoteFromCache();
|
||||||
|
|
||||||
if (note.hasLabel("archived")) {
|
if (!note || note.hasLabel("archived")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1754,7 +1756,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
for (const nodeToDuplicate of nodesToDuplicate) {
|
for (const nodeToDuplicate of nodesToDuplicate) {
|
||||||
const note = froca.getNoteFromCache(nodeToDuplicate.data.noteId);
|
const note = froca.getNoteFromCache(nodeToDuplicate.data.noteId);
|
||||||
|
|
||||||
if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
|
if (note?.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user