mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 21:36:05 +01:00
frontend attribute cache refactoring WIP
This commit is contained in:
@@ -533,6 +533,37 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
}
|
||||
}
|
||||
|
||||
syncDataListener({data}) {
|
||||
const noteIdsToRefresh = new Set();
|
||||
|
||||
// this has the problem that the former parentNoteId might not be invalidated
|
||||
// and the former location of the branch/note won't be removed.
|
||||
data.filter(sync => sync.entityName === 'branches').forEach(sync => {
|
||||
const branch = treeCache.getBranch(sync.entityId);
|
||||
// we assume that the cache contains the old branch state and we add also the old parentNoteId
|
||||
// so that the old parent can also be updated
|
||||
noteIdsToRefresh.add(branch.parentNoteId);
|
||||
|
||||
noteIdsToRefresh.add(sync.parentNoteId);
|
||||
});
|
||||
|
||||
data.filter(sync => sync.entityName === 'notes').forEach(sync => noteIdsToRefresh.add(sync.entityId));
|
||||
|
||||
data.filter(sync => sync.entityName === 'note_reordering').forEach(sync => noteIdsToRefresh.add(sync.entityId));
|
||||
|
||||
data.filter(sync => sync.entityName === 'attributes').forEach(sync => {
|
||||
const note = treeCache.notes[sync.noteId];
|
||||
|
||||
if (note && note.__attributeCache) {
|
||||
noteIdsToRefresh.add(sync.entityId);
|
||||
}
|
||||
});
|
||||
|
||||
if (noteIdsToRefresh.size > 0) {
|
||||
appContext.trigger('reloadNotes', {noteIds: Array.from(noteIdsToRefresh)});
|
||||
}
|
||||
}
|
||||
|
||||
hoistedNoteChangedListener() {
|
||||
this.reloadTreeListener();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import server from "../../services/server.js";
|
||||
import noteDetailService from "../../services/note_detail.js";
|
||||
import linkService from "../../services/link.js";
|
||||
import libraryLoader from "../../services/library_loader.js";
|
||||
import treeService from "../../services/tree.js";
|
||||
|
||||
Reference in New Issue
Block a user