Compare commits

...

9 Commits

12 changed files with 46 additions and 39 deletions

View File

@@ -44,7 +44,7 @@ find $DIR/node_modules -name demo -exec rm -rf {} \;
find $DIR/libraries -name "*.map" -type f -delete
rm -r $DIR/src/public/app
rm -rf $DIR/src/public/app
sed -i -e 's/app\/desktop.js/app-dist\/desktop.js/g' $DIR/src/views/desktop.ejs
sed -i -e 's/app\/mobile.js/app-dist\/mobile.js/g' $DIR/src/views/mobile.ejs

View File

@@ -1,3 +1,13 @@
-- delete duplicates https://github.com/zadam/trilium/issues/2534
DELETE FROM entity_changes WHERE isErased = 0 AND id IN (
SELECT id FROM entity_changes ec
WHERE (
SELECT COUNT(*) FROM entity_changes
WHERE ec.entityName = entity_changes.entityName
AND ec.entityId = entity_changes.entityId
) > 1
);
CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`entityName` TEXT NOT NULL,
@@ -10,8 +20,8 @@ CREATE TABLE IF NOT EXISTS "mig_entity_changes" (
`utcDateChanged` TEXT NOT NULL
);
INSERT INTO mig_entity_changes (entityName, entityId, hash, isErased, changeId, sourceId, isSynced, utcDateChanged)
SELECT entityName, entityId, hash, isErased, '', sourceId, isSynced, utcDateChanged FROM entity_changes;
INSERT INTO mig_entity_changes (id, entityName, entityId, hash, isErased, changeId, sourceId, isSynced, utcDateChanged)
SELECT id, entityName, entityId, hash, isErased, '', sourceId, isSynced, utcDateChanged FROM entity_changes;
DROP TABLE entity_changes;

View File

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

View File

@@ -71,14 +71,7 @@ function getNoteTitle(childNoteId, parentNoteId) {
return "[error fetching title]";
}
let title;
if (childNote.isProtected) {
title = protectedSessionService.isProtectedSessionAvailable() ? childNote.title : '[protected]';
}
else {
title = childNote.title;
}
const title = childNote.getTitleOrProtected();
const branch = parentNote ? becca.getBranchFromChildAndParent(childNote.noteId, parentNote.noteId) : null;

View File

@@ -131,6 +131,10 @@ class Note extends AbstractEntity {
|| protectedSessionService.isProtectedSessionAvailable()
}
getTitleOrProtected() {
return this.isContentAvailable() ? this.title : '[protected]';
}
/** @returns {Branch[]} */
getParentBranches() {
return this.parentBranches;

View File

@@ -98,7 +98,7 @@ function getLinkMap(req) {
return [
note.noteId,
note.isContentAvailable() ? note.title : '[protected]',
note.getTitleOrProtected(),
note.type
];
});
@@ -158,7 +158,7 @@ function getTreeMap(req) {
.concat(...mapRootNote.getParentNotes())
.map(note => [
note.noteId,
note.isContentAvailable() ? note.title : '[protected]',
note.getTitleOrProtected(),
note.type
]);

View File

@@ -54,7 +54,7 @@ function getNotesAndBranchesAndAttributes(noteIds) {
notes.push({
noteId: note.noteId,
title: note.isDecrypted ? note.title : '[protected]',
title: note.getTitleOrProtected(),
isProtected: note.isProtected,
type: note.type,
mime: note.mime

View File

@@ -1 +1 @@
module.exports = { buildDate:"2022-01-06T23:09:17+01:00", buildRevision: "590eea11830531699643b381d06a6a59dd7704bb" };
module.exports = { buildDate:"2022-01-09T22:32:13+01:00", buildRevision: "be59f248e8387c268471946da99979939c8d2c1d" };

View File

@@ -97,7 +97,8 @@ function exportToZip(taskContext, branch, format, res) {
return;
}
const completeTitle = branch.prefix ? (branch.prefix + ' - ' + note.title) : note.title;
const title = note.getTitleOrProtected();
const completeTitle = branch.prefix ? (branch.prefix + ' - ' + title) : title;
let baseFileName = sanitize(completeTitle);
if (baseFileName.length > 200) { // actual limit is 256 bytes(!) but let's be conservative
@@ -113,7 +114,7 @@ function exportToZip(taskContext, branch, format, res) {
isClone: true,
noteId: note.noteId,
notePath: notePath,
title: note.title,
title: note.getTitleOrProtected(),
prefix: branch.prefix,
dataFileName: fileName,
type: 'text', // export will have text description,
@@ -125,7 +126,7 @@ function exportToZip(taskContext, branch, format, res) {
isClone: false,
noteId: note.noteId,
notePath: notePath,
title: note.title,
title: note.getTitleOrProtected(),
notePosition: branch.notePosition,
prefix: branch.prefix,
isExpanded: branch.isExpanded,
@@ -445,7 +446,7 @@ ${content}
}
const note = branch.getNote();
const zipFileName = (branch.prefix ? `${branch.prefix} - ` : "") + note.title + ".zip";
const zipFileName = (branch.prefix ? `${branch.prefix} - ` : "") + note.getTitleOrProtected() + ".zip";
res.setHeader('Content-Disposition', utils.getContentDisposition(zipFileName));
res.setHeader('Content-Type', 'application/zip');

View File

@@ -102,8 +102,9 @@ function createNewNote(params) {
throw new Error(`Parent note "${params.parentNoteId}" not found.`);
}
if (!params.title || params.title.trim().length === 0) {
throw new Error(`Note title must not be empty`);
if (params.title === null || params.title === undefined) {
// empty title is allowed since it's possible to create such in the UI
throw new Error(`Note title must be set`);
}
return sql.transactional(() => {

View File

@@ -149,8 +149,8 @@ async function pullChanges(syncContext) {
sql.transactional(() => {
for (const {entityChange, entity} of entityChanges) {
const changeAppliedAlready = !entityChange.changeId
|| !!sql.getValue("SELECT id FROM entity_changes WHERE changeId = ?", [entityChange.changeId]);
const changeAppliedAlready = entityChange.changeId
&& !!sql.getValue("SELECT id FROM entity_changes WHERE changeId = ?", [entityChange.changeId]);
if (!changeAppliedAlready && !sourceIdService.isLocalSourceId(entityChange.sourceId)) {
if (!atLeastOnePullApplied) { // send only for first

View File

@@ -29,7 +29,7 @@
<div id="main">
<% if (note.parents[0].noteId !== 'share' && note.parents.length !== 0) { %>
<nav id="parentLink">
parent: <a href="<%= note.parents[0].noteId %>"
parent: <a href="<%= note.parents[0].shareId %>"
class="type-<%= note.parents[0].type %>"><%= note.parents[0].title %></a>
</nav>
<% } %>
@@ -40,10 +40,7 @@
<div id="noteClippedFrom">This note was originally clipped from <a href="<%= note.getLabelValue("pageUrl") %>"><%= note.getLabelValue("pageUrl") %></a></div>
<% } %>
<% if (note.type === 'book') { %>
<% } else if (isEmpty) { %>
<p>This note has no content.</p>
<% } else { %>
<% if (!isEmpty) { %>
<div id="content" class="type-<%= note.type %><% if (note.type === 'text') { %> ck-content<% } %>">
<%- content %>
</div>
@@ -52,20 +49,21 @@
<% if (note.hasChildren()) { %>
<nav id="childLinks" class="<% if (isEmpty) { %>grid<% } else { %>list<% } %>">
<% if (!isEmpty) { %>
<div id="noteClippedFrom">
<hr>
<span>Child notes: </span>
<ul>
<% for (const childNote of note.getChildNotes()) { %>
<li>
<a href="<%= childNote.shareId %>"
class="type-<%= childNote.type %>"><%= childNote.title %></a>
</li>
<% } %>
</ul>
</div>
<% } %>
<ul>
<% for (const childNote of note.getChildNotes()) { %>
<li>
<a href="<%= childNote.shareId %>"
class="type-<%= childNote.type %>"><%= childNote.title %></a>
</li>
<% } %>
</ul>
</nav>
<% } else if (isEmpty) { %>
<p>This note has no content.</p>
<% } %>
</div>