mirror of
https://github.com/zadam/trilium.git
synced 2025-02-24 15:05:31 +08:00
fix filing entity changes for deleted notes
This commit is contained in:
parent
346f6edd7e
commit
c67644a2e3
2 changed files with 31 additions and 5 deletions
|
@ -152,6 +152,10 @@ class Becca {
|
|||
.replace('_', '')
|
||||
);
|
||||
|
||||
if (!(camelCaseEntityName in this)) {
|
||||
throw new Error(`Unknown entity name '${camelCaseEntityName}' (original argument '${entityName}')`);
|
||||
}
|
||||
|
||||
return this[camelCaseEntityName][entityId];
|
||||
}
|
||||
|
||||
|
|
|
@ -100,16 +100,38 @@ function fillEntityChanges(entityName, entityPrimaryKey, condition = '') {
|
|||
if (existingRows === 0) {
|
||||
createdCount++;
|
||||
|
||||
const entity = becca.getEntity(entityName, entityId);
|
||||
let hash;
|
||||
let utcDateChanged;
|
||||
let isSynced;
|
||||
|
||||
if (entityName.endsWith("_contents")) {
|
||||
// FIXME: hacky, not sure if it might cause some problems
|
||||
hash = "fake value";
|
||||
utcDateChanged = dateUtils.utcNowDateTime();
|
||||
isSynced = true; // contents are always synced
|
||||
} else {
|
||||
const entity = becca.getEntity(entityName, entityId);
|
||||
|
||||
if (entity) {
|
||||
hash = entity?.generateHash() || "|deleted";
|
||||
utcDateChanged = entity?.getUtcDateChanged() || dateUtils.utcNowDateTime();
|
||||
isSynced = entityName !== 'options' || !!entity?.isSynced;
|
||||
} else {
|
||||
// entity might be null (not present in becca) when it's deleted
|
||||
// FIXME: hacky, not sure if it might cause some problems
|
||||
hash = "deleted";
|
||||
utcDateChanged = dateUtils.utcNowDateTime();
|
||||
isSynced = true; // deletable (the ones with isDeleted) entities are synced
|
||||
}
|
||||
}
|
||||
|
||||
// entity might be null (not present in becca) when it's deleted
|
||||
addEntityChange({
|
||||
entityName,
|
||||
entityId,
|
||||
hash: entity?.generateHash() || "|deleted",
|
||||
hash: hash,
|
||||
isErased: false,
|
||||
utcDateChanged: entity?.getUtcDateChanged() || dateUtils.utcNowDateTime(),
|
||||
isSynced: entityName !== 'options' || !!entity?.isSynced
|
||||
utcDateChanged: utcDateChanged,
|
||||
isSynced: isSynced
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue