mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 02:30:42 +01:00
smaller refactorings
This commit is contained in:
@@ -19,15 +19,13 @@ async function cloneNoteToParent(req) {
|
||||
const maxNotePos = await sql.getValue('SELECT MAX(notePosition) FROM branches WHERE parentNoteId = ? AND isDeleted = 0', [parentNoteId]);
|
||||
const newNotePos = maxNotePos === null ? 0 : maxNotePos + 1;
|
||||
|
||||
const branch = new Branch({
|
||||
const branch = await new Branch({
|
||||
noteId: noteId,
|
||||
parentNoteId: parentNoteId,
|
||||
prefix: prefix,
|
||||
notePosition: newNotePos,
|
||||
isExpanded: 0
|
||||
});
|
||||
|
||||
await branch.save();
|
||||
}).save();
|
||||
|
||||
await sql.execute("UPDATE branches SET isExpanded = 1 WHERE noteId = ?", [parentNoteId]);
|
||||
|
||||
@@ -53,14 +51,12 @@ async function cloneNoteAfter(req) {
|
||||
|
||||
await syncTable.addNoteReorderingSync(afterNote.parentNoteId);
|
||||
|
||||
const branch = new Branch({
|
||||
const branch = await new Branch({
|
||||
noteId: noteId,
|
||||
parentNoteId: afterNote.parentNoteId,
|
||||
notePosition: afterNote.notePosition + 1,
|
||||
isExpanded: 0
|
||||
});
|
||||
|
||||
await branch.save();
|
||||
}).save();
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
@@ -24,14 +24,12 @@ async function addRecentNote(req) {
|
||||
const branchId = req.params.branchId;
|
||||
const notePath = req.params.notePath;
|
||||
|
||||
const recentNote = new RecentNote({
|
||||
await new RecentNote({
|
||||
branchId: branchId,
|
||||
notePath: notePath,
|
||||
dateAccessed: dateUtils.nowDate(),
|
||||
isDeleted: 0
|
||||
});
|
||||
|
||||
await recentNote.save();
|
||||
}).save();
|
||||
|
||||
await optionService.setOption('startNotePath', notePath);
|
||||
|
||||
|
||||
@@ -20,8 +20,9 @@ async function login(req) {
|
||||
return [401, "Incorrect username/password"];
|
||||
}
|
||||
|
||||
const apiToken = new ApiToken({ token: utils.randomSecureToken() });
|
||||
await apiToken.save();
|
||||
const apiToken = await new ApiToken({
|
||||
token: utils.randomSecureToken()
|
||||
}).save();
|
||||
|
||||
return {
|
||||
token: apiToken.token
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const optionService = require('../../services/options');
|
||||
const config = require('../../services/config');
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
|
||||
async function getTree() {
|
||||
|
||||
Reference in New Issue
Block a user