fix(share): Prevent crashing if candidate note is null (#8164)

This commit is contained in:
Elian Doran 2025-12-29 20:43:12 +02:00 committed by GitHub
commit 758df0d85a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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 = (() => {