Compare commits

..

4 Commits

Author SHA1 Message Date
Elian Doran
758df0d85a fix(share): Prevent crashing if candidate note is null (#8164) 2025-12-29 20:43:12 +02:00
Elian Doran
59bbd902fc feat(share): Render JS Frontend files as-is with extension .js (#8172) 2025-12-29 20:41:46 +02:00
Wael Nasreddine
cb016c4307 Address Gemini's comment 2025-12-25 16:26:58 -08:00
Wael Nasreddine
7c7797d35a 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
2025-12-25 16:11:01 -08:00

View File

@@ -15,13 +15,17 @@
// 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()) {
const children = candidate.getVisibleChildNotes();
const lastChild = children[children.length - 1];
candidate = lastChild;
while (candidate?.hasVisibleChildren()) {
const visibleChildren = candidate.getVisibleChildNotes();
if (visibleChildren.length === 0) {
break;
}
candidate = visibleChildren[visibleChildren.length - 1];
}
return candidate;
return candidate ?? null;
})();
const nextNote = (() => {