mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 22:05:44 +01:00
image upload fixes + some API changes
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
|
||||
const sql = require('./sql');
|
||||
const syncTable = require('./sync_table');
|
||||
const tree = require('./tree');
|
||||
const treeService = require('./tree');
|
||||
const noteService = require('./notes');
|
||||
const repository = require('./repository');
|
||||
const Branch = require('../entities/branch');
|
||||
|
||||
async function cloneNoteToParent(noteId, parentNoteId, prefix) {
|
||||
const validationResult = await tree.validateParentChild(parentNoteId, noteId);
|
||||
const validationResult = await treeService.validateParentChild(parentNoteId, noteId);
|
||||
|
||||
if (!validationResult.success) {
|
||||
return validationResult;
|
||||
@@ -24,10 +26,24 @@ async function cloneNoteToParent(noteId, parentNoteId, prefix) {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
async function cloneNoteAfter(noteId, afterBranchId) {
|
||||
const afterNote = await tree.getBranch(afterBranchId);
|
||||
// this is identical to cloneNoteToParent except for the intention - if cloned note is already in parent,
|
||||
// then this is successful result
|
||||
async function ensureNoteIsPresentInParent(noteId, parentNoteId, prefix) {
|
||||
await cloneNoteToParent(noteId, parentNoteId, prefix);
|
||||
}
|
||||
|
||||
const validationResult = await tree.validateParentChild(afterNote.parentNoteId, noteId);
|
||||
async function ensureNoteIsAbsentFromParent(noteId, parentNoteId) {
|
||||
const branch = await repository.getEntity(`SELECT * FROM branches WHERE noteId = ? AND parentNoteId = ? AND isDeleted = 0`, [noteId, parentNoteId]);
|
||||
|
||||
if (branch) {
|
||||
await noteService.deleteNote(branch);
|
||||
}
|
||||
}
|
||||
|
||||
async function cloneNoteAfter(noteId, afterBranchId) {
|
||||
const afterNote = await treeService.getBranch(afterBranchId);
|
||||
|
||||
const validationResult = await treeService.validateParentChild(afterNote.parentNoteId, noteId);
|
||||
|
||||
if (!validationResult.result) {
|
||||
return validationResult;
|
||||
@@ -52,5 +68,7 @@ async function cloneNoteAfter(noteId, afterBranchId) {
|
||||
|
||||
module.exports = {
|
||||
cloneNoteToParent,
|
||||
ensureNoteIsPresentInParent,
|
||||
ensureNoteIsAbsentFromParent,
|
||||
cloneNoteAfter
|
||||
};
|
||||
Reference in New Issue
Block a user