we're now saving links also for notes included in relation maps which helps with translation of noteIds during import from native tar

This commit is contained in:
azivner 2018-11-16 23:27:57 +01:00
parent 3fee263355
commit 6a36e1ca86
4 changed files with 27 additions and 5 deletions

View File

@ -549,6 +549,8 @@ async function dropNoteOntoRelationMapHandler(ev) {
}
}
saveData();
await refresh();
}

View File

@ -263,7 +263,8 @@ async function runAllChecks() {
links
WHERE
type != 'image'
AND type != 'hyper'`,
AND type != 'hyper'
AND type != 'relation-map'`,
"Link type is invalid", errorList);
await runCheck(`

View File

@ -202,7 +202,7 @@ async function importNotes(ctx, files, parentNoteId) {
isExpanded: !!file.meta.isExpanded
}).save();
return;
continue;
}
if (file.meta.type !== 'file' && file.meta.type !== 'image') {

View File

@ -199,15 +199,34 @@ function findHyperLinks(content, foundLinks) {
return match;
}
function findRelationMapLinks(content, foundLinks) {
const obj = JSON.parse(content);
for (const note of obj.notes) {
foundLinks.push({
type: 'relation-map',
targetNoteId: note.noteId
})
}
}
async function saveLinks(note) {
if (note.type !== 'text') {
if (note.type !== 'text' && note.type !== 'relation-map') {
return;
}
const foundLinks = [];
findImageLinks(note.content, foundLinks);
findHyperLinks(note.content, foundLinks);
if (note.type === 'text') {
findImageLinks(note.content, foundLinks);
findHyperLinks(note.content, foundLinks);
}
else if (note.type === 'relation-map') {
findRelationMapLinks(note.content, foundLinks);
}
else {
throw new Error("Unrecognized type " + note.type);
}
const existingLinks = await note.getLinks();