mirror of
https://github.com/zadam/trilium.git
synced 2025-02-22 14:03:36 +08:00
promise for loaded note cache
This commit is contained in:
parent
c72ea2ed60
commit
edc23940d0
2 changed files with 11 additions and 1 deletions
|
@ -40,6 +40,8 @@ async function getNotes(noteIds) {
|
|||
|
||||
protectedSessionService.decryptNotes(notes);
|
||||
|
||||
await noteCacheService.loadedPromise;
|
||||
|
||||
notes.forEach(note => {
|
||||
note.isProtected = !!note.isProtected;
|
||||
note.archived = noteCacheService.isArchived(note.noteId)
|
||||
|
|
|
@ -8,6 +8,12 @@ const hoistedNoteService = require('./hoisted_note');
|
|||
const stringSimilarity = require('string-similarity');
|
||||
|
||||
let loaded = false;
|
||||
let loadedPromiseResolve;
|
||||
/** Is resolved after the initial load */
|
||||
let loadedPromise = new Promise(res => {
|
||||
loadedPromiseResolve = res;
|
||||
});
|
||||
|
||||
let noteTitles = {};
|
||||
let protectedNoteTitles = {};
|
||||
let noteIds;
|
||||
|
@ -43,6 +49,7 @@ async function load() {
|
|||
}
|
||||
|
||||
loaded = true;
|
||||
loadedPromiseResolve();
|
||||
}
|
||||
|
||||
async function loadProtectedNotes() {
|
||||
|
@ -499,9 +506,10 @@ eventService.subscribe(eventService.ENTER_PROTECTED_SESSION, () => {
|
|||
}
|
||||
});
|
||||
|
||||
sqlInit.dbReady.then(() => utils.stopWatch("Autocomplete load", load));
|
||||
sqlInit.dbReady.then(() => utils.stopWatch("Note cache load", load));
|
||||
|
||||
module.exports = {
|
||||
loadedPromise,
|
||||
findNotes,
|
||||
getNotePath,
|
||||
getNoteTitleForPath,
|
||||
|
|
Loading…
Reference in a new issue