mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fixed "duplicate subtree"
This commit is contained in:
parent
f528799fed
commit
08cba1e1ce
@ -41,7 +41,7 @@ class Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getUtcDateChanged() {
|
getUtcDateChanged() {
|
||||||
return this.utcDateModified || this.utcDateCreated;
|
return this.utcDateModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
get repository() {
|
get repository() {
|
||||||
|
@ -47,6 +47,7 @@ async function remove(url, sourceId) {
|
|||||||
|
|
||||||
let i = 1;
|
let i = 1;
|
||||||
const reqResolves = {};
|
const reqResolves = {};
|
||||||
|
const reqRejects = {};
|
||||||
|
|
||||||
let maxKnownEntityChangeId = 0;
|
let maxKnownEntityChangeId = 0;
|
||||||
|
|
||||||
@ -63,6 +64,7 @@ async function call(method, url, data, headers = {}) {
|
|||||||
|
|
||||||
resp = await new Promise((resolve, reject) => {
|
resp = await new Promise((resolve, reject) => {
|
||||||
reqResolves[requestId] = resolve;
|
reqResolves[requestId] = resolve;
|
||||||
|
reqRejects[requestId] = reject;
|
||||||
|
|
||||||
if (REQUEST_LOGGING_ENABLED) {
|
if (REQUEST_LOGGING_ENABLED) {
|
||||||
console.log(utils.now(), "Request #" + requestId + " to " + method + " " + url);
|
console.log(utils.now(), "Request #" + requestId + " to " + method + " " + url);
|
||||||
@ -96,6 +98,14 @@ async function call(method, url, data, headers = {}) {
|
|||||||
return resp.body;
|
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) {
|
function ajax(url, method, data, headers) {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
const options = {
|
const options = {
|
||||||
@ -117,11 +127,8 @@ function ajax(url, method, data, headers) {
|
|||||||
headers: respHeaders
|
headers: respHeaders
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
error: async (jqXhr, textStatus, error) => {
|
error: async (jqXhr, status, error) => {
|
||||||
const message = "Error when calling " + method + " " + url + ": " + textStatus + " - " + error;
|
await reportError(method, url, status, error);
|
||||||
const toastService = (await import("./toast.js")).default;
|
|
||||||
toastService.showError(message);
|
|
||||||
toastService.throwError(message);
|
|
||||||
|
|
||||||
rej(error);
|
rej(error);
|
||||||
}
|
}
|
||||||
@ -143,17 +150,25 @@ function ajax(url, method, data, headers) {
|
|||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
const ipc = utils.dynamicRequire('electron').ipcRenderer;
|
const ipc = utils.dynamicRequire('electron').ipcRenderer;
|
||||||
|
|
||||||
ipc.on('server-response', (event, arg) => {
|
ipc.on('server-response', async (event, arg) => {
|
||||||
if (REQUEST_LOGGING_ENABLED) {
|
if (REQUEST_LOGGING_ENABLED) {
|
||||||
console.log(utils.now(), "Response #" + arg.requestId + ": " + arg.statusCode);
|
console.log(utils.now(), "Response #" + arg.requestId + ": " + arg.statusCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
reqResolves[arg.requestId]({
|
if (arg.statusCode >= 200 && arg.statusCode < 300) {
|
||||||
body: arg.body,
|
reqResolves[arg.requestId]({
|
||||||
headers: arg.headers
|
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 reqResolves[arg.requestId];
|
||||||
|
delete reqRejects[arg.requestId];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,12 @@ const mentionSetup = {
|
|||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="note-detail-editable-text note-detail-printable">
|
<div class="note-detail-editable-text note-detail-printable">
|
||||||
<style>
|
<style>
|
||||||
|
.note-detail-editable-text {
|
||||||
|
font-family: var(--detail-text-font-family);
|
||||||
|
padding-left: 12px;
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.note-detail-editable-text a:hover {
|
.note-detail-editable-text a:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@ -53,11 +59,6 @@ const TPL = `
|
|||||||
.note-detail-editable-text h6 { font-size: 1.1em; }
|
.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 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 {
|
.note-detail-editable-text-editor {
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
border: 0 !important;
|
border: 0 !important;
|
||||||
|
@ -26,7 +26,8 @@ const TPL = `
|
|||||||
.note-detail-readonly-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }
|
.note-detail-readonly-text h6::before { content: "######\\2004"; color: var(--muted-text-color); }
|
||||||
|
|
||||||
.note-detail-readonly-text {
|
.note-detail-readonly-text {
|
||||||
padding: 10px;
|
padding-left: 22px;
|
||||||
|
padding-top: 10px;
|
||||||
font-family: var(--detail-text-font-family);
|
font-family: var(--detail-text-font-family);
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ function init(app) {
|
|||||||
},
|
},
|
||||||
send: obj => {
|
send: obj => {
|
||||||
event.sender.send('server-response', {
|
event.sender.send('server-response', {
|
||||||
|
url: arg.url,
|
||||||
|
method: arg.method,
|
||||||
requestId: arg.requestId,
|
requestId: arg.requestId,
|
||||||
statusCode: res.statusCode,
|
statusCode: res.statusCode,
|
||||||
headers: respHeaders,
|
headers: respHeaders,
|
||||||
|
@ -759,7 +759,7 @@ function duplicateSubtree(origNoteId, newParentNoteId) {
|
|||||||
throw new Error('Duplicating root is not possible');
|
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);
|
const origNote = repository.getNote(origNoteId);
|
||||||
// might be null if orig note is not in the target newParentNoteId
|
// 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) {
|
function duplicateSubtreeInner(origNote, origBranch, newParentNoteId, noteIdMapping) {
|
||||||
if (origNote.isProtected && !protectedSessionService.isProtectedSessionAvailable()) {
|
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);
|
const newNote = new Note(origNote);
|
||||||
@ -821,7 +821,6 @@ function duplicateSubtreeInner(origNote, origBranch, newParentNoteId, noteIdMapp
|
|||||||
for (const attribute of origNote.getOwnedAttributes()) {
|
for (const attribute of origNote.getOwnedAttributes()) {
|
||||||
const attr = new Attribute(attribute);
|
const attr = new Attribute(attribute);
|
||||||
attr.attributeId = undefined; // force creation of new attribute
|
attr.attributeId = undefined; // force creation of new attribute
|
||||||
attr.utcDateCreated = dateUtils.utcNowDateTime();
|
|
||||||
attr.noteId = newNote.noteId;
|
attr.noteId = newNote.noteId;
|
||||||
|
|
||||||
// if relation points to within the duplicated tree then replace the target to the duplicated note
|
// if relation points to within the duplicated tree then replace the target to the duplicated note
|
||||||
|
Loading…
x
Reference in New Issue
Block a user