Skip to content

Build your personal knowledge base with Trilium Notes

cleaned up images and links which are not used nor supported

azivner3386cd790e5b
diff --git a/public/javascripts/note_editor.js b/public/javascripts/note_editor.js
index 6053e3ea52..5bc286c02b 100644
--- a/public/javascripts/note_editor.js
+++ b/public/javascripts/note_editor.js
@@ -59,31 +59,8 @@ const noteEditor = (function() {
}
}
- function parseHtml(contents, note) {
- note.links = [];
- note.images = [];
-
- note.detail.note_text = contents;
-
- if (!note.detail.is_protected) {
- const linkRegexp = /<a[^>]+?href="[^"]*app#([A-Za-z0-9/]+)"[^>]*?>[^<]+?<\/a>/g;
- let match;
-
- while (match = linkRegexp.exec(contents)) {
- console.log("adding link for " + match[1]);
-
- note.links.push({
- note_id: note.detail.note_id,
- target_note_id: match[1]
- });
- }
- }
- }
-
function updateNoteFromInputs(note) {
- const contents = noteDetailEl.summernote('code');
-
- parseHtml(contents, note);
+ note.detail.note_text = noteDetailEl.summernote('code');
const title = noteTitleEl.val();
diff --git a/routes/api/notes.js b/routes/api/notes.js
index d08d5a1101..44d96371b2 100644
--- a/routes/api/notes.js
+++ b/routes/api/notes.js
@@ -31,7 +31,6 @@ router.get('/:noteId', auth.checkApiAuth, async (req, res, next) => {
res.send({
detail: detail,
- images: await sql.getResults("SELECT * FROM images WHERE note_id = ? order by note_offset", [detail.note_id]),
loadTime: utils.nowTimestamp()
});
});
diff --git a/routes/api/sync.js b/routes/api/sync.js
index c5494ce729..18fc9c640d 100644
--- a/routes/api/sync.js
+++ b/routes/api/sync.js
@@ -30,8 +30,7 @@ router.get('/notes/:noteId', auth.checkApiAuth, async (req, res, next) => {
const noteId = req.params.noteId;
res.send({
- entity: await sql.getSingleResult("SELECT * FROM notes WHERE note_id = ?", [noteId]),
- links: await sql.getResults("SELECT * FROM links WHERE note_id = ?", [noteId])
+ entity: await sql.getSingleResult("SELECT * FROM notes WHERE note_id = ?", [noteId])
});
});
@@ -74,7 +73,7 @@ router.get('/recent_notes/:notePath', auth.checkApiAuth, async (req, res, next)
});
router.put('/notes', auth.checkApiAuth, async (req, res, next) => {
- await syncUpdate.updateNote(req.body.entity, req.body.links, req.body.sourceId);
+ await syncUpdate.updateNote(req.body.entity, req.body.sourceId);
res.send({});
});
diff --git a/services/backup.js b/services/backup.js
index 0ef9fdbaf5..513ba932e3 100644
--- a/services/backup.js
+++ b/services/backup.js
@@ -5,6 +5,7 @@ const options = require('./options');
const fs = require('fs-extra');
const dataDir = require('./data_dir');
const log = require('./log');
+const sql = require('./sql');
async function regularBackup() {
const now = utils.nowTimestamp();
diff --git a/services/notes.js b/services/notes.js
index 664e227697..8b817dd84c 100644
--- a/services/notes.js
+++ b/services/notes.js
@@ -171,20 +171,6 @@ async function updateNote(noteId, newNote, ctx) {
now,
noteId]);
- await sql.remove("images", noteId);
-
- for (const img of newNote.images) {
- img.image_data = atob(img.image_data);
-
- await sql.insert("images", img);
- }
-
- await sql.remove("links", noteId);
-
- for (const link in newNote.links) {
- //await sql.insert("links", link);
- }
-
await sync_table.addNoteSync(noteId);
});
}
diff --git a/services/sync.js b/services/sync.js
index 9277a4ba6d..43686c69f0 100644
--- a/services/sync.js
+++ b/services/sync.js
@@ -136,7 +136,7 @@ async function pullSync(syncContext) {
}
if (sync.entity_name === 'notes') {
- await syncUpdate.updateNote(resp.entity, resp.links, syncContext.sourceId);
+ await syncUpdate.updateNote(resp.entity, syncContext.sourceId);
}
else if (sync.entity_name === 'notes_tree') {
await syncUpdate.updateNoteTree(resp, syncContext.sourceId);
@@ -167,6 +167,12 @@ async function getLastSyncedPush() {
return parseInt(await options.getOption('last_synced_push'));
}
+async function setLastSyncedPush(lastSyncedPush) {
+ await sql.doInTransaction(async () => {
+ await options.setOption('last_synced_push', lastSyncedPush);
+ });
+}
+
async function pushSync(syncContext) {
let lastSyncedPush = await getLastSyncedPush();
@@ -190,9 +196,7 @@ async function pushSync(syncContext) {
lastSyncedPush = sync.id;
- await sql.doInTransaction(async () => {
- await options.setOption('last_synced_push', lastSyncedPush);
- });
+ await setLastSyncedPush(lastSyncedPush);
}
}
@@ -240,10 +244,6 @@ async function sendEntity(syncContext, entity, entityName) {
entity: entity
};
- if (entityName === 'notes') {
- payload.links = await sql.getResults('SELECT * FROM links WHERE note_id = ?', [entity.note_id]);
- }
-
await syncRequest(syncContext, 'PUT', '/api/sync/' + entityName, payload);
}
diff --git a/services/sync_update.js b/services/sync_update.js
index d10cb69f8e..034fe03f10 100644
--- a/services/sync_update.js
+++ b/services/sync_update.js
@@ -6,21 +6,13 @@ const eventLog = require('./event_log');
const notes = require('./notes');
const sync_table = require('./sync_table');
-async function updateNote(entity, links, sourceId) {
+async function updateNote(entity, sourceId) {
const origNote = await sql.getSingleResult("SELECT * FROM notes WHERE note_id = ?", [entity.note_id]);
if (!origNote || origNote.date_modified <= entity.date_modified) {
await sql.doInTransaction(async () => {
await sql.replace("notes", entity);
- await sql.remove("links", entity.note_id);
-
- for (const link of links) {
- delete link['lnk_id'];
-
- //await sql.insert('link', link);
- }
-
await sync_table.addNoteSync(entity.note_id, sourceId);
await eventLog.addNoteEvent(entity.note_id, "Synced note <note>");
});