A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
core: publish database updated event on relations unlink
Abdullah Atta9dff23bdd555
diff --git a/packages/core/src/collections/relations.ts b/packages/core/src/collections/relations.tsindex c094211b1..9d4452157 100644--- a/packages/core/src/collections/relations.ts+++ b/packages/core/src/collections/relations.ts@@ -19,13 +19,20 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.import { makeId } from "../utils/id";import { ICollection } from "./collection";-import { Relation, ItemMap, ItemReference, ValueOf, ItemType } from "../types";+import {+ Relation,+ ItemMap,+ ItemReference,+ ItemReferences,+ ValueOf,+ UnlinkEvent+} from "../types";import Database from "../api";import { FilteredSelector, SQLCollection } from "../database/sql-collection";import { DatabaseSchema, isFalse } from "../database";import { SelectQueryBuilder } from "kysely";+import { EVENTS } from "../common";-type ItemReferences = { type: ItemType; ids: string[] };export class Relations implements ICollection {name = "relations";readonly collection: SQLCollection<"relations", Relation>;@@ -167,6 +174,21 @@ export class Relations implements ICollection {])).execute();++ this.db.eventManager.publish(EVENTS.databaseUpdated, <UnlinkEvent>{+ collection: "relations",+ type: "unlink",+ reference: { type: type, ids: ids || [] },+ direction: "from",+ types: Object.keys(TABLE_MAP)+ });+ this.db.eventManager.publish(EVENTS.databaseUpdated, <UnlinkEvent>{+ collection: "relations",+ type: "unlink",+ reference: { type: type, ids: ids || [] },+ direction: "to",+ types: Object.keys(TABLE_MAP)+ });}}@@ -257,6 +279,14 @@ class RelationsArray<TType extends keyof RelatableTable> {])).execute();++ this.db.eventManager.publish(EVENTS.databaseUpdated, <UnlinkEvent>{+ collection: "relations",+ type: "unlink",+ reference: this.reference,+ direction: this.direction,+ types: this.types+ });}async get() {