mirror of
https://github.com/zadam/trilium.git
synced 2025-12-31 11:44:23 +01:00
fix(share/prev_next): Prevent crashing if candide page is null
When a note is not visible, attempting to export it ends up crashing the
server with this error:
```
TypeError: ejs:193
191|
192| <% if (hasTree) { %>
>> 193| <%- include("prev_next", { note: note, subRoot: subRoot }) %>
194| <% } %>
195| </footer>
196| </div>
ejs:1
>> 1| <%
2| // TODO: code cleanup + putting this behind a toggle/attribute
3| const previousNote = (() => {
4| // If we are at the subRoot, there is no previous
Cannot read properties of undefined (reading 'hasVisibleChildren')
at eval (eval at compile (/usr/src/app/main.cjs:553:203), <anonymous>:27:26)
at eval (eval at compile (/usr/src/app/main.cjs:553:203), <anonymous>:34:7)
at d (/usr/src/app/main.cjs:557:265)
at g (/usr/src/app/main.cjs:557:251)
at eval (eval at compile (/usr/src/app/main.cjs:553:203), <anonymous>:293:17)
at d (/usr/src/app/main.cjs:557:265)
at as.render (/usr/src/app/main.cjs:532:458)
at Omr (/usr/src/app/main.cjs:581:109552)
at Rmr (/usr/src/app/main.cjs:581:107637)
at $W.prepareContent (/usr/src/app/main.cjs:653:28) {
path: ''
```
fixes #8002
fixes #8162
This commit is contained in:
parent
8d6eb6fa53
commit
7c7797d35a
@ -15,13 +15,12 @@
|
||||
// We are not the first child at this level so previous
|
||||
// should go to the end of the previous tree
|
||||
let candidate = children[index - 1];
|
||||
while (candidate.hasVisibleChildren()) {
|
||||
while (candidate?.hasVisibleChildren()) {
|
||||
const children = candidate.getVisibleChildNotes();
|
||||
const lastChild = children[children.length - 1];
|
||||
candidate = lastChild;
|
||||
candidate = children[children.length - 1];
|
||||
}
|
||||
|
||||
return candidate;
|
||||
return candidate ?? null;
|
||||
})();
|
||||
|
||||
const nextNote = (() => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user