trilium/src/public/javascripts/services/load_results.js

70 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-01-28 05:58:03 +08:00
export class LoadResults {
2020-01-30 04:38:58 +08:00
constructor(treeCache) {
this.treeCache = treeCache;
2020-01-30 03:14:02 +08:00
this.noteIdToSourceId = {};
2020-01-28 05:58:03 +08:00
this.sourceIdToNoteIds = {};
2020-01-30 03:14:02 +08:00
this.branchIdToSourceId = {};
2020-01-28 05:58:03 +08:00
}
2020-01-29 04:54:28 +08:00
addNote(noteId, sourceId) {
2020-01-30 03:14:02 +08:00
this.noteIdToSourceId[noteId] = this.noteIdToSourceId[noteId] || [];
2020-01-28 05:58:03 +08:00
2020-01-30 03:14:02 +08:00
if (!this.noteIdToSourceId[noteId].includes(sourceId)) {
this.noteIdToSourceId[noteId].push(sourceId);
2020-01-28 05:58:03 +08:00
}
this.sourceIdToNoteIds[sourceId] = this.sourceIdToNoteIds[sourceId] || [];
if (!this.sourceIdToNoteIds[sourceId]) {
this.sourceIdToNoteIds[sourceId].push(noteId);
}
}
2020-01-30 03:14:02 +08:00
addBranch(branchId, sourceId) {
this.branchIdToSourceId[branchId] = this.branchIdToSourceId[branchId] || [];
this.branchIdToSourceId[branchId].push(sourceId);
}
2020-01-30 04:38:58 +08:00
getBranches() {
}
2020-01-30 03:14:02 +08:00
addNoteReordering(parentNoteId, sourceId) {
}
2020-01-30 04:38:58 +08:00
getNoteReorderings() {
}
2020-01-30 03:14:02 +08:00
addAttribute(attributeId, sourceId) {
}
2020-01-30 04:38:58 +08:00
getAttributes() {
}
addNoteRevision(noteRevisionId, noteId, sourceId) {
}
hasNoteRevisionForNote(noteId) {
}
2020-01-28 05:58:03 +08:00
getNoteIds() {
2020-01-30 03:14:02 +08:00
return Object.keys(this.noteIdToSourceId);
2020-01-28 05:58:03 +08:00
}
isNoteReloaded(noteId, sourceId) {
2020-01-29 04:54:28 +08:00
if (!noteId) {
return false;
}
2020-01-30 03:14:02 +08:00
const sourceIds = this.noteIdToSourceId[noteId];
2020-01-28 05:58:03 +08:00
return sourceIds && !!sourceIds.find(sId => sId !== sourceId);
}
}