fix for cloned notes at root level + better logging

This commit is contained in:
azivner 2017-12-06 20:11:45 -05:00
parent a0bbd8c853
commit 0c6521545a
3 changed files with 14 additions and 3 deletions

View File

@ -4,7 +4,7 @@ const messaging = (function() {
let ws = null;
function logError(message) {
console.error(message);
console.trace(message);
if (ws && ws.readyState === 1) {
ws.send(JSON.stringify({

View File

@ -278,7 +278,9 @@ const noteTree = (function() {
const list = $("<ul/>");
for (const parentNoteId of parents) {
const notePath = getSomeNotePath(parentNoteId) + '/' + noteId;
const parentNotePath = getSomeNotePath(parentNoteId);
// this is to avoid having root notes leading '/'
const notePath = parentNotePath ? (parentNotePath + '/' + noteId) : noteId;
const title = getNotePathTitle(notePath);
let item;
@ -302,12 +304,19 @@ const noteTree = (function() {
let parentNoteId = 'root';
console.log('notePath: ' + notePath);
console.log('notePath chunks: ', notePath.split('/'));
for (const noteId of notePath.split('/')) {
console.log('noteId: ' + noteId);
titlePath.push(getNoteTitle(noteId, parentNoteId));
parentNoteId = noteId;
}
console.log("Title path:", titlePath.join(' / '));
return titlePath.join(' / ');
}

View File

@ -31,7 +31,9 @@ function showError(message) {
}
function throwError(message) {
throw new Error(message + ':' + new Error().stack);
messaging.logError(message);
throw new Error(message);
}
function getDateFromTS(timestamp) {