mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 20:06:08 +01:00
configuration of displayed link types + max number of links
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
|
||||
async function getLinks(noteIds) {
|
||||
return await sql.getManyRows(`
|
||||
async function getLinks(noteIds, linkTypes) {
|
||||
return (await sql.getManyRows(`
|
||||
SELECT noteId, targetNoteId, type
|
||||
FROM links
|
||||
WHERE (noteId IN (???) OR targetNoteId IN (???))
|
||||
@@ -14,17 +14,18 @@ async function getLinks(noteIds) {
|
||||
WHERE (noteId IN (???) OR value IN (???))
|
||||
AND type = 'relation'
|
||||
AND isDeleted = 0
|
||||
`, Array.from(noteIds));
|
||||
`, Array.from(noteIds))).filter(l => linkTypes.includes(l.type));
|
||||
}
|
||||
|
||||
async function getLinkMap(req) {
|
||||
const {noteId} = req.params;
|
||||
const {linkTypes, maxNotes} = req.body;
|
||||
|
||||
let noteIds = new Set([noteId]);
|
||||
let links = [];
|
||||
|
||||
while (true) {
|
||||
const newLinks = await getLinks(noteIds);
|
||||
const newLinks = await getLinks(noteIds, linkTypes);
|
||||
const newNoteIds = new Set(newLinks.map(l => l.noteId).concat(newLinks.map(l => l.targetNoteId)));
|
||||
|
||||
if (newNoteIds.size === noteIds.size) {
|
||||
@@ -32,7 +33,7 @@ async function getLinkMap(req) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (newNoteIds.length > 50) {
|
||||
if (newNoteIds.size > maxNotes) {
|
||||
// to many notes to display
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user