small refactorings

This commit is contained in:
zadam
2023-05-04 22:16:18 +02:00
parent ecd2a5cbac
commit 8edf06d28d
28 changed files with 49 additions and 44 deletions

View File

@@ -252,14 +252,16 @@ class FNote {
const targetRelations = this.getTargetRelations().filter(relation => relation.name === 'imageLink');
if (targetRelations.length !== 1) {
if (targetRelations.length > 1) {
return false;
}
const parentNote = this.getParentNotes()[0]; // at this point note can have only one parent
const referencingNote = targetRelations[0].getNote();
const referencingNote = targetRelations[0]?.getNote();
if (parentNote !== referencingNote || parentNote.type !== 'text' || !parentNote.isContentAvailable()) {
if (referencingNote && referencingNote !== parentNote) {
return false;
} else if (parentNote.type !== 'text' || !parentNote.isContentAvailable()) {
return false;
}