Merge branch 'master' into dev31

This commit is contained in:
zadam 2019-03-10 10:11:01 +01:00
commit 05374becfd
12 changed files with 40 additions and 15 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "trilium", "name": "trilium",
"version": "0.30.3-beta", "version": "0.30.4",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -2,7 +2,7 @@
"name": "trilium", "name": "trilium",
"productName": "Trilium Notes", "productName": "Trilium Notes",
"description": "Trilium Notes", "description": "Trilium Notes",
"version": "0.30.3-beta", "version": "0.30.4",
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"main": "electron.js", "main": "electron.js",
"bin": { "bin": {

View File

@ -106,7 +106,7 @@ class Note extends Entity {
/** @returns {Promise} */ /** @returns {Promise} */
async setJsonContent(content) { async setJsonContent(content) {
await this.setContent(JSON.stringify(content)); await this.setContent(JSON.stringify(content, null, '\t'));
} }
/** @returns {boolean} true if this note is the root of the note tree. Root note has "root" noteId */ /** @returns {boolean} true if this note is the root of the note tree. Root note has "root" noteId */

View File

@ -137,6 +137,10 @@ function linkTypeChanged() {
$linkTypes.change(linkTypeChanged); $linkTypes.change(linkTypeChanged);
// return back focus to note text detail after quitting add link
// the problem is that cursor position is reset
$dialog.on("hidden.bs.modal", () => noteDetailText.focus());
export default { export default {
showDialog showDialog
}; };

View File

@ -9,6 +9,8 @@ async function getAndExecuteBundle(noteId, originEntity = null) {
} }
async function executeBundle(bundle, originEntity) { async function executeBundle(bundle, originEntity) {
console.log(bundle);
const apiContext = await ScriptContext(bundle.noteId, bundle.allNoteIds, originEntity); const apiContext = await ScriptContext(bundle.noteId, bundle.allNoteIds, originEntity);
try { try {
@ -17,7 +19,7 @@ async function executeBundle(bundle, originEntity) {
}.call(apiContext)); }.call(apiContext));
} }
catch (e) { catch (e) {
infoService.showAndLogError(`Execution of script "${bundle.note.title}" (${bundle.note.noteId}) failed with error: ${e.message}`); infoService.showAndLogError(`Execution of ${bundle.noteId} failed with error: ${e.message}`);
} }
} }

View File

@ -117,7 +117,10 @@ async function saveNote() {
} }
note.title = $noteTitle.val(); note.title = $noteTitle.val();
note.noteContent.content = getCurrentNoteContent(note);
if (note.noteContent != null) { // might be null for file/image
note.noteContent.content = getCurrentNoteContent(note);
}
// it's important to set the flag back to false immediatelly after retrieving title and content // it's important to set the flag back to false immediatelly after retrieving title and content
// otherwise we might overwrite another change (especially async code) // otherwise we might overwrite another change (especially async code)

View File

@ -910,4 +910,9 @@ a.external:after, a[href^="http://"]:after, a[href^="https://"]:after {
font-size: smaller; font-size: smaller;
content: "\2197"; content: "\2197";
vertical-align: top; vertical-align: top;
}
.card {
background-color: inherit !important;
border-color: var(--main-border-color) !important;
} }

View File

@ -1 +1 @@
module.exports = { buildDate:"2019-03-03T20:47:50+01:00", buildRevision: "95d8f07458853dbad08964e7ec1af1d50792b0a2" }; module.exports = { buildDate:"2019-03-07T22:40:05+01:00", buildRevision: "02eddc347abebce63a8882f6f83ac73655005849" };

View File

@ -357,6 +357,13 @@ async function findLogicIssues() {
logFix(`Removed link ${linkId} because target note ${targetNoteId} is also deleted.`); logFix(`Removed link ${linkId} because target note ${targetNoteId} is also deleted.`);
}); });
await findIssues(`
SELECT noteId
FROM notes
JOIN note_contents USING(noteId)
WHERE notes.isDeleted = 0 AND notes.isProtected != note_contents.isProtected`,
({noteId}) => `Note ${noteId} has inconsistent isProtected in notes and note_contents tables`);
} }
async function runSyncRowChecks(entityName, key) { async function runSyncRowChecks(entityName, key) {

View File

@ -116,7 +116,7 @@ async function getDateNote(dateStr) {
dateNote = await createNote(monthNote.noteId, noteTitle); dateNote = await createNote(monthNote.noteId, noteTitle);
} }
await attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr); await attributeService.createLabel(dateNote.noteId, DATE_LABEL, dateStr.substr(0, 10));
} }
return dateNote; return dateNote;

View File

@ -332,19 +332,21 @@ async function updateNote(noteId, noteUpdates) {
const noteTitleChanged = note.title !== noteUpdates.title; const noteTitleChanged = note.title !== noteUpdates.title;
noteUpdates.noteContent.content = await saveLinks(note, noteUpdates.noteContent.content);
note.title = noteUpdates.title; note.title = noteUpdates.title;
note.isProtected = noteUpdates.isProtected; note.isProtected = noteUpdates.isProtected;
await note.save(); await note.save();
if (note.type !== 'file' && note.type !== 'image') { const noteContent = await note.getNoteContent();
const noteContent = await note.getNoteContent();
if (!['file', 'image'].includes(note.type)) {
noteUpdates.noteContent.content = await saveLinks(note, noteUpdates.noteContent.content);
noteContent.content = noteUpdates.noteContent.content; noteContent.content = noteUpdates.noteContent.content;
noteContent.isProtected = noteUpdates.isProtected;
await noteContent.save();
} }
noteContent.isProtected = noteUpdates.isProtected;
await noteContent.save();
if (noteTitleChanged) { if (noteTitleChanged) {
await triggerNoteTitleChanged(note); await triggerNoteTitleChanged(note);
} }

View File

@ -15,7 +15,7 @@ function setDataKey(decryptedDataKey) {
} }
function setProtectedSessionId(req) { function setProtectedSessionId(req) {
cls.namespace.set('protectedSessionId', req.headers['trilium-protected-session-id']); cls.namespace.set('protectedSessionId', req.headers['trilium-protected-session-id'] || req.query.protectedSessionId);
} }
function getProtectedSessionId() { function getProtectedSessionId() {
@ -62,7 +62,9 @@ function decryptNoteContent(noteContent) {
} }
try { try {
noteContent.content = dataEncryptionService.decrypt(getDataKey(), noteContent.content); if (noteContent.content != null) {
noteContent.content = dataEncryptionService.decrypt(getDataKey(), noteContent.content.toString());
}
} }
catch (e) { catch (e) {
e.message = `Cannot decrypt note content for noteContentId=${noteContent.noteContentId}: ` + e.message; e.message = `Cannot decrypt note content for noteContentId=${noteContent.noteContentId}: ` + e.message;