improvements in frontend sync (WIP)

This commit is contained in:
zadam 2021-08-24 22:37:00 +02:00
parent 0ee093f038
commit d27fcaf317
6 changed files with 68 additions and 10924 deletions

View File

@ -5,7 +5,7 @@ if [[ $# -eq 0 ]] ; then
exit 1
fi
n exec 14.17.2 npm run webpack
n exec 14.17.5 npm run webpack
DIR=$1
@ -27,7 +27,7 @@ cp -r electron.js $DIR/
cp webpack-* $DIR/
# run in subshell (so we return to original dir)
(cd $DIR && n exec 14.17.2 npm install --only=prod)
(cd $DIR && n exec 14.17.5 npm install --only=prod)
# cleanup of useless files in dependencies
rm -r $DIR/node_modules/image-q/demo

10948
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -81,12 +81,12 @@
},
"devDependencies": {
"cross-env": "7.0.3",
"electron": "13.2.1",
"electron": "13.2.2",
"electron-builder": "22.11.7",
"electron-packager": "15.3.0",
"electron-rebuild": "3.2.0",
"esm": "3.2.25",
"jasmine": "3.8.0",
"jasmine": "3.9.0",
"jsdoc": "3.6.7",
"lorem-ipsum": "2.0.3",
"rcedit": "3.0.1",

View File

@ -82,13 +82,14 @@ function processNoteChange(loadResults, ec) {
return;
}
loadResults.addNote(ec.entityId, ec.sourceId);
if (ec.isErased || ec.entity?.isDeleted) {
delete froca.notes[ec.entityId];
return;
}
else {
note.update(ec.entity);
loadResults.addNote(ec.entityId, ec.sourceId);
}
}
function processBranchChange(loadResults, ec) {
@ -109,12 +110,16 @@ function processBranchChange(loadResults, ec) {
delete parentNote.childToBranch[branch.noteId];
}
loadResults.addBranch(ec.entityId, ec.sourceId);
delete froca.branches[ec.entityId];
}
return;
}
loadResults.addBranch(ec.entityId, ec.sourceId);
const childNote = froca.notes[ec.entity.noteId];
const parentNote = froca.notes[ec.entity.parentNoteId];
@ -125,8 +130,6 @@ function processBranchChange(loadResults, ec) {
froca.branches[branch.branchId] = branch = new Branch(froca, ec.entity);
}
loadResults.addBranch(ec.entityId, ec.sourceId);
if (childNote) {
childNote.addParent(branch.parentNoteId, branch.branchId);
}
@ -176,25 +179,26 @@ function processAttributeChange(loadResults, ec) {
targetNote.targetRelations = targetNote.targetRelations.filter(attributeId => attributeId !== attribute.attributeId);
}
loadResults.addAttribute(ec.entityId, ec.sourceId);
delete froca.attributes[ec.entityId];
}
return;
}
loadResults.addAttribute(ec.entityId, ec.sourceId);
const sourceNote = froca.notes[ec.entity.noteId];
const targetNote = ec.entity.type === 'relation' && froca.notes[ec.entity.value];
if (attribute) {
attribute.update(ec.entity);
loadResults.addAttribute(ec.entityId, ec.sourceId);
} else if (sourceNote || targetNote) {
attribute = new Attribute(froca, ec.entity);
froca.attributes[attribute.attributeId] = attribute;
loadResults.addAttribute(ec.entityId, ec.sourceId);
if (sourceNote && !sourceNote.attributes.includes(attribute.attributeId)) {
sourceNote.attributes.push(attribute.attributeId);
}

View File

@ -201,7 +201,7 @@ class NoteContext extends Component {
async entitiesReloadedEvent({loadResults}) {
if (loadResults.isNoteReloaded(this.noteId)) {
const note = await froca.getNote(this.noteId);
const note = loadResults.getEntity('notes', this.noteId);
if (note.isDeleted) {
this.noteId = null;

View File

@ -842,12 +842,10 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
/** @return {FancytreeNode[]} */
getNodesByBranchId(branchId) {
utils.assertArguments(branchId);
getNodesByBranch(branch) {
utils.assertArguments(branch);
const branch = froca.getBranch(branchId);
return this.getNodesByNoteId(branch.noteId).filter(node => node.data.branchId === branchId);
return this.getNodesByNoteId(branch.noteId).filter(node => node.data.branchId === branch.branchId);
}
/** @return {FancytreeNode[]} */
@ -1002,7 +1000,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
// adding noteId itself to update all potential clones
noteIdsToUpdate.add(branch.noteId);
for (const node of this.getNodesByBranchId(branch.branchId)) {
for (const node of this.getNodesByBranch(branch)) {
if (branch.isDeleted) {
if (node.isActive()) {
const newActiveNode = node.getNextSibling()