Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: send event when directly unlinking a relation

Abdullah Attaa04cd6b8dcce
diff --git a/packages/core/src/collections/relations.ts b/packages/core/src/collections/relations.ts
index a6a6a1111..a5883cabe 100644
--- a/packages/core/src/collections/relations.ts
+++ b/packages/core/src/collections/relations.ts
@@ -152,8 +152,15 @@ export class Relations implements ICollection {
await this.collection.softDelete(ids);
}
- unlink(from: ItemReference, to: ItemReference) {
- return this.remove(generateId(from, to));
+ async unlink(from: ItemReference, to: ItemReference) {
+ await this.remove(generateId(from, to));
+ this.db.eventManager.publish(EVENTS.databaseUpdated, <UnlinkEvent>{
+ collection: "relations",
+ type: "unlink",
+ reference: to,
+ direction: "from",
+ types: [from.type]
+ });
}
async unlinkOfType(type: keyof RelatableTable, ids?: string[]) {