date note fixes

This commit is contained in:
zadam 2019-10-27 22:13:38 +01:00
parent e04845335b
commit b7344329f4
4 changed files with 7 additions and 18 deletions

View File

@ -8,27 +8,21 @@ async function getTodayNote() {
/** @return {NoteShort} */ /** @return {NoteShort} */
async function getDateNote(date) { async function getDateNote(date) {
const note = await server.get('date-notes/date/' + date); const note = await server.get('date-notes/date/' + date, {'trilium-source-id': "date-note"});
await treeCache.reloadNotes([note.noteId]);
return await treeCache.getNote(note.noteId); return await treeCache.getNote(note.noteId);
} }
/** @return {NoteShort} */ /** @return {NoteShort} */
async function getMonthNote(month) { async function getMonthNote(month) {
const note = await server.get('date-notes/month/' + month); const note = await server.get('date-notes/month/' + month, {'trilium-source-id': "date-note"});
await treeCache.reloadNotes([note.noteId]);
return await treeCache.getNote(note.noteId); return await treeCache.getNote(note.noteId);
} }
/** @return {NoteShort} */ /** @return {NoteShort} */
async function getYearNote(year) { async function getYearNote(year) {
const note = await server.get('date-notes/year/' + year); const note = await server.get('date-notes/year/' + year, {'trilium-source-id': "date-note"});
await treeCache.reloadNotes([note.noteId]);
return await treeCache.getNote(note.noteId); return await treeCache.getNote(note.noteId);
} }

View File

@ -64,15 +64,15 @@ async function call(method, url, data, headers = {}) {
}); });
} }
else { else {
return await ajax(url, method, data); return await ajax(url, method, data, headers);
} }
} }
async function ajax(url, method, data) { async function ajax(url, method, data, headers) {
const options = { const options = {
url: baseApiUrl + url, url: baseApiUrl + url,
type: method, type: method,
headers: getHeaders(), headers: getHeaders(headers),
timeout: 60000 timeout: 60000
}; };

View File

@ -55,8 +55,6 @@ class TreeCache {
if (childNote) { if (childNote) {
childNote.parents = childNote.parents.filter(p => p !== noteId); childNote.parents = childNote.parents.filter(p => p !== noteId);
console.log("Cleaning up", childNote.parentToBranch[noteId]);
delete this.branches[childNote.parentToBranch[noteId]]; delete this.branches[childNote.parentToBranch[noteId]];
delete childNote.parentToBranch[noteId]; delete childNote.parentToBranch[noteId];
} }
@ -75,10 +73,6 @@ class TreeCache {
} }
for (const branch of branchesByNotes[noteId] || []) { // can be empty for deleted notes for (const branch of branchesByNotes[noteId] || []) { // can be empty for deleted notes
if (noteId === '2Ndfjyv3EbEQ') {
console.log("Adding", branch.branchId);
}
this.branches[branch.branchId] = branch; this.branches[branch.branchId] = branch;
} }

View File

@ -14,6 +14,7 @@ const syncOptions = require('./sync_options');
const syncMutexService = require('./sync_mutex'); const syncMutexService = require('./sync_mutex');
const cls = require('./cls'); const cls = require('./cls');
const request = require('./request'); const request = require('./request');
const ws = require('./ws');
let proxyToggle = true; let proxyToggle = true;