mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 02:30:42 +01:00
smaller refactorings (mostly entitization)
This commit is contained in:
@@ -58,7 +58,7 @@ async function createNewNote(parentNoteId, noteOpts) {
|
||||
mime: noteOpts.mime ? noteOpts.mime : 'text/html'
|
||||
});
|
||||
|
||||
await repository.updateEntity(note);
|
||||
await note.save();
|
||||
|
||||
const branch = new Branch({
|
||||
branchId: utils.newBranchId(),
|
||||
@@ -69,12 +69,13 @@ async function createNewNote(parentNoteId, noteOpts) {
|
||||
isDeleted: 0
|
||||
});
|
||||
|
||||
await repository.updateEntity(branch);
|
||||
await branch.save();
|
||||
|
||||
return {
|
||||
noteId: note.noteId,
|
||||
note,
|
||||
branchId: branch.branchId,
|
||||
note
|
||||
branch
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,6 @@ function getDataKey() {
|
||||
return dataKeyMap[protectedSessionId];
|
||||
}
|
||||
|
||||
function getDataKeyForProtectedSessionId(protectedSessionId) {
|
||||
return dataKeyMap[protectedSessionId];
|
||||
}
|
||||
|
||||
function isProtectedSessionAvailable(req) {
|
||||
const protectedSessionId = getProtectedSessionId(req);
|
||||
|
||||
@@ -84,12 +80,6 @@ function decryptNoteRevision(hist) {
|
||||
}
|
||||
}
|
||||
|
||||
function decryptNoteRevisions(noteRevisions) {
|
||||
for (const revision of noteRevisions) {
|
||||
decryptNoteRevision(revision);
|
||||
}
|
||||
}
|
||||
|
||||
function encryptNote(note) {
|
||||
const dataKey = getDataKey();
|
||||
|
||||
@@ -107,12 +97,10 @@ function encryptNoteRevision(revision) {
|
||||
module.exports = {
|
||||
setDataKey,
|
||||
getDataKey,
|
||||
getDataKeyForProtectedSessionId,
|
||||
isProtectedSessionAvailable,
|
||||
decryptNote,
|
||||
decryptNotes,
|
||||
decryptNoteRevision,
|
||||
decryptNoteRevisions,
|
||||
encryptNote,
|
||||
encryptNoteRevision,
|
||||
setProtectedSessionId
|
||||
|
||||
@@ -33,6 +33,10 @@ async function getBranch(branchId) {
|
||||
return await getEntity("SELECT * FROM branches WHERE branchId = ?", [branchId]);
|
||||
}
|
||||
|
||||
async function getImage(imageId) {
|
||||
return await getEntity("SELECT * FROM images WHERE imageId = ?", [imageId]);
|
||||
}
|
||||
|
||||
async function updateEntity(entity) {
|
||||
if (entity.beforeSaving) {
|
||||
entity.beforeSaving();
|
||||
@@ -54,6 +58,7 @@ module.exports = {
|
||||
getEntity,
|
||||
getNote,
|
||||
getBranch,
|
||||
getImage,
|
||||
updateEntity,
|
||||
setEntityConstructor
|
||||
};
|
||||
Reference in New Issue
Block a user