From 8e2cc15cab11c7f0f2c94a8fb2c3101c964d7173 Mon Sep 17 00:00:00 2001 From: geoffreychen777 Date: Wed, 28 Feb 2024 14:41:12 +0000 Subject: [PATCH] Fix: #385 quickpast window cannot export citatin keys. --- app/renderer/services/reference-service.ts | 2 +- .../db-repository/categorizer-repository.ts | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/renderer/services/reference-service.ts b/app/renderer/services/reference-service.ts index 5cefa24e..1243e9d2 100644 --- a/app/renderer/services/reference-service.ts +++ b/app/renderer/services/reference-service.ts @@ -351,7 +351,7 @@ export class ReferenceService { case "BibTex": copyStr = this.exportBibTexBody(this.toCite(paperEntityDrafts)); break; - case "BibTexKey": + case "BibTex-Key": copyStr = this.exportBibTexKey(this.toCite(paperEntityDrafts)); break; case "PlainText": diff --git a/app/repositories/db-repository/categorizer-repository.ts b/app/repositories/db-repository/categorizer-repository.ts index 37c88a16..666e4bd8 100644 --- a/app/repositories/db-repository/categorizer-repository.ts +++ b/app/repositories/db-repository/categorizer-repository.ts @@ -57,10 +57,22 @@ export class CategorizerRepository extends Eventable( - type, - new Realm.BSON.ObjectId(categorizer._id) - ); + let object: ICategorizerObject | null; + if (categorizer._id) { + object = realm.objectForPrimaryKey( + type, + new Realm.BSON.ObjectId(categorizer._id) + ); + } else { + const objects = realm + .objects(type) + .filtered(`name == "${categorizer.name}"`); + if (objects.length > 0) { + object = objects[0]; + } else { + object = null; + } + } return object as ICategorizerRealmObject | null; } }