froca should not keep any deleted notes

This commit is contained in:
zadam 2021-05-09 22:00:21 +02:00
parent d8d15b528e
commit 5d58520949
4 changed files with 12 additions and 5 deletions

View file

@ -61,8 +61,6 @@ class NoteShort {
this.type = row.type;
/** @param {string} content-type, e.g. "application/json" */
this.mime = row.mime;
/** @param {boolean} */
this.isDeleted = !!row.isDeleted;
}
addParent(parentNoteId, branchId) {

View file

@ -72,7 +72,7 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
if (logErrors) {
const parent = froca.getNoteFromCache(parentNoteId);
console.log(utils.now(), `Did not find parent ${parentNoteId} (${parent ? parent.title : 'n/a'}) for child ${childNoteId} (${child.title}), available parents: ${parents.map(p => `${p.noteId} (${p.title})`)}`);
console.debug(utils.now(), `Did not find parent ${parentNoteId} (${parent ? parent.title : 'n/a'}) for child ${childNoteId} (${child.title}), available parents: ${parents.map(p => `${p.noteId} (${p.title})`)}. You can ignore this message as it is mostly harmless.`);
}
const someNotePath = getSomeNotePath(child, hoistedNoteId);

View file

@ -219,8 +219,13 @@ async function processEntityChanges(entityChanges) {
const note = froca.notes[ec.entityId];
if (note) {
note.update(ec.entity);
loadResults.addNote(ec.entityId, ec.sourceId);
if (ec.entity.isDeleted) {
delete froca.notes[ec.entityId];
}
else {
note.update(ec.entity);
loadResults.addNote(ec.entityId, ec.sourceId);
}
}
}

View file

@ -75,6 +75,10 @@ function sendMessageToAllClients(message) {
}
function fillInAdditionalProperties(entityChange) {
// most of these could be filled by becca
// the exception is isDeleted - in that case becca doesn't contain such entity at all
// this would have to be handled separately
// fill in some extra data needed by the frontend
if (entityChange.entityName === 'attributes') {
entityChange.entity = sql.getRow(`SELECT * FROM attributes WHERE attributeId = ?`, [entityChange.entityId]);