Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fixed "duplicate subtree"
zadam08cba1e1ce5d
diff --git a/src/entities/entity.js b/src/entities/entity.jsindex 1bb6525831..f24f2d1b14 100644--- a/src/entities/entity.js+++ b/src/entities/entity.js@@ -41,7 +41,7 @@ class Entity {}getUtcDateChanged() {- return this.utcDateModified || this.utcDateCreated;+ return this.utcDateModified;}get repository() {diff --git a/src/public/app/services/server.js b/src/public/app/services/server.jsindex 59ffe8aeeb..0abde554a1 100644--- a/src/public/app/services/server.js+++ b/src/public/app/services/server.js@@ -47,6 +47,7 @@ async function remove(url, sourceId) {let i = 1;const reqResolves = {};+const reqRejects = {};let maxKnownEntityChangeId = 0;@@ -63,6 +64,7 @@ async function call(method, url, data, headers = {}) {resp = await new Promise((resolve, reject) => {reqResolves[requestId] = resolve;+ reqRejects[requestId] = reject;if (REQUEST_LOGGING_ENABLED) {console.log(utils.now(), "Request #" + requestId + " to " + method + " " + url);@@ -96,6 +98,14 @@ async function call(method, url, data, headers = {}) {return resp.body;}+async function reportError(method, url, status, error) {+ const message = "Error when calling " + method + " " + url + ": " + status + " - " + error;++ const toastService = (await import("./toast.js")).default;+ toastService.showError(message);+ toastService.throwError(message);+}+function ajax(url, method, data, headers) {return new Promise((res, rej) => {const options = {@@ -117,11 +127,8 @@ function ajax(url, method, data, headers) {headers: respHeaders});},- error: async (jqXhr, textStatus, error) => {- const message = "Error when calling " + method + " " + url + ": " + textStatus + " - " + error;- const toastService = (await import("./toast.js")).default;- toastService.showError(message);- toastService.throwError(message);+ error: async (jqXhr, status, error) => {+ await reportError(method, url, status, error);rej(error);}@@ -143,17 +150,25 @@ function ajax(url, method, data, headers) {if (utils.isElectron()) {const ipc = utils.dynamicRequire('electron').ipcRenderer;- ipc.on('server-response', (event, arg) => {+ ipc.on('server-response', async (event, arg) => {if (REQUEST_LOGGING_ENABLED) {console.log(utils.now(), "Response #" + arg.requestId + ": " + arg.statusCode);}- reqResolves[arg.requestId]({- body: arg.body,- headers: arg.headers- });+ if (arg.statusCode >= 200 && arg.statusCode < 300) {+ reqResolves[arg.requestId]({+ body: arg.body,+ headers: arg.headers+ });+ }+ else {+ await reportError(arg.method, arg.url, arg.statusCode, arg.body);++ reqRejects[arg.requestId]();+ }delete reqResolves[arg.requestId];+ delete reqRejects[arg.requestId];});}diff --git a/src/public/app/widgets/type_widgets/editable_text.js b/src/public/app/widgets/type_widgets/editable_text.jsindex 93b0f984cb..f7f33c0797 100644--- a/src/public/app/widgets/type_widgets/editable_text.js+++ b/src/public/app/widgets/type_widgets/editable_text.js@@ -30,6 +30,12 @@ const mentionSetup = {const TPL = `<div class="note-detail-editable-text note-detail-printable"><style>+ .note-detail-editable-text {+ font-family: var(--detail-text-font-family);+ padding-left: 12px;+ padding-top: 10px;+ }+.note-detail-editable-text a:hover {cursor: pointer;}@@ -53,11 +59,6 @@ const TPL = `.note-detail-editable-text h6 { font-size: 1.1em; }.note-detail-editable-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }- .note-detail-editable-text {- font-family: var(--detail-text-font-family);- padding-left: 12px;- }-.note-detail-editable-text-editor {padding-top: 10px;border: 0 !important;diff --git a/src/public/app/widgets/type_widgets/read_only_text.js b/src/public/app/widgets/type_widgets/read_only_text.jsindex da997c65f3..c34eb510f1 100644--- a/src/public/app/widgets/type_widgets/read_only_text.js+++ b/src/public/app/widgets/type_widgets/read_only_text.js@@ -26,7 +26,8 @@ const TPL = `.note-detail-readonly-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }.note-detail-readonly-text {- padding: 10px;+ padding-left: 22px;+ padding-top: 10px;font-family: var(--detail-text-font-family);position: relative;}diff --git a/src/routes/electron.js b/src/routes/electron.jsindex 3589382d26..38fa5e704c 100644--- a/src/routes/electron.js+++ b/src/routes/electron.js@@ -26,6 +26,8 @@ function init(app) {},send: obj => {event.sender.send('server-response', {+ url: arg.url,+ method: arg.method,requestId: arg.requestId,statusCode: res.statusCode,headers: respHeaders,@@ -38,4 +40,4 @@ function init(app) {});}-module.exports = init;\ No newline at end of file+module.exports = init;diff --git a/src/services/notes.js b/src/services/notes.jsindex 8df6ddd0cb..62b0f5f655 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -759,7 +759,7 @@ function duplicateSubtree(origNoteId, newParentNoteId) {throw new Error('Duplicating root is not possible');}- log.info(`Duplicating ${origNote} subtree into ${newParentNoteId}`);+ log.info(`Duplicating ${origNoteId} subtree into ${newParentNoteId}`);const origNote = repository.getNote(origNoteId);// might be null if orig note is not in the target newParentNoteId@@ -793,7 +793,7 @@ function duplicateSubtreeWithoutRoot(origNoteId, newNoteId) {function duplicateSubtreeInner(origNote, origBranch, newParentNoteId, noteIdMapping) {if (origNote.isProtected && !protectedSessionService.isProtectedSessionAvailable()) {- throw new Error(`Cannot duplicate note=${origNote.noteId} because it is protected and protected session is not available`);+ throw new Error(`Cannot duplicate note=${origNote.noteId} because it is protected and protected session is not available. Enter protected session and try again.`);}const newNote = new Note(origNote);@@ -821,7 +821,6 @@ function duplicateSubtreeInner(origNote, origBranch, newParentNoteId, noteIdMappfor (const attribute of origNote.getOwnedAttributes()) {const attr = new Attribute(attribute);attr.attributeId = undefined; // force creation of new attribute- attr.utcDateCreated = dateUtils.utcNowDateTime();attr.noteId = newNote.noteId;// if relation points to within the duplicated tree then replace the target to the duplicated note