mirror of
https://github.com/zadam/trilium.git
synced 2025-11-09 14:55:50 +01:00
improvements in frontend sync (WIP)
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
export default class LoadResults {
|
||||
constructor(froca) {
|
||||
this.froca = froca;
|
||||
constructor(entityChanges) {
|
||||
this.entities = {};
|
||||
|
||||
for (const {entityId, entityName, entity} of entityChanges) {
|
||||
if (entity) {
|
||||
this.entities[entityName] = this.entities[entityName] || [];
|
||||
this.entities[entityName][entityId] = entity;
|
||||
}
|
||||
}
|
||||
|
||||
this.noteIdToSourceId = {};
|
||||
this.sourceIdToNoteIds = {};
|
||||
@@ -18,6 +25,10 @@ export default class LoadResults {
|
||||
this.options = [];
|
||||
}
|
||||
|
||||
getEntity(entityName, entityId) {
|
||||
return this.entities[entityName]?.[entityId];
|
||||
}
|
||||
|
||||
addNote(noteId, sourceId) {
|
||||
this.noteIdToSourceId[noteId] = this.noteIdToSourceId[noteId] || [];
|
||||
|
||||
@@ -38,7 +49,7 @@ export default class LoadResults {
|
||||
|
||||
getBranches() {
|
||||
return this.branches
|
||||
.map(row => this.froca.branches[row.branchId])
|
||||
.map(row => this.getEntity("branches", row.branchId))
|
||||
.filter(branch => !!branch);
|
||||
}
|
||||
|
||||
@@ -58,7 +69,7 @@ export default class LoadResults {
|
||||
getAttributes(sourceId = 'none') {
|
||||
return this.attributes
|
||||
.filter(row => row.sourceId !== sourceId)
|
||||
.map(row => this.froca.attributes[row.attributeId])
|
||||
.map(row => this.getEntity("attributes", row.attributeId))
|
||||
.filter(attr => !!attr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user