From 6f0fd4219e87b6d587d46627c8dd53321f0bdd18 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 9 Feb 2024 11:55:29 +0000 Subject: [PATCH] Desktop: Make OCR results available to search immediately after completion --- packages/app-desktop/app.ts | 6 +++++- packages/app-desktop/package.json | 2 +- packages/lib/eventManager.ts | 1 + packages/lib/services/ResourceService.ts | 3 +++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/app-desktop/app.ts b/packages/app-desktop/app.ts index 8fb1fbc347d..2c2c621b286 100644 --- a/packages/app-desktop/app.ts +++ b/packages/app-desktop/app.ts @@ -624,7 +624,11 @@ class Application extends BaseApplication { await this.setupOcrService(); - eventManager.on(EventName.OcrServiceResourcesProcessed, () => { + eventManager.on(EventName.OcrServiceResourcesProcessed, async () => { + await ResourceService.instance().indexNoteResources(); + }); + + eventManager.on(EventName.NoteResourceIndexed, async () => { SearchEngine.instance().scheduleSyncTables(); }); diff --git a/packages/app-desktop/package.json b/packages/app-desktop/package.json index ed257cb7796..8d370d88e41 100644 --- a/packages/app-desktop/package.json +++ b/packages/app-desktop/package.json @@ -11,7 +11,7 @@ "electronRebuild": "gulp electronRebuild", "tsc": "tsc --project tsconfig.json", "watch": "tsc --watch --preserveWatchOutput --project tsconfig.json", - "start": "gulp before-start && electron . --env dev --log-level debug --open-dev-tools", + "start": "gulp before-start && electron . --env dev --log-level debug --open-dev-tools --no-welcome", "test": "jest", "test-ui": "playwright test", "test-ci": "yarn test && sh ./integration-tests/run-ci.sh", diff --git a/packages/lib/eventManager.ts b/packages/lib/eventManager.ts index 60d4d5e8c64..157a0b02f57 100644 --- a/packages/lib/eventManager.ts +++ b/packages/lib/eventManager.ts @@ -17,6 +17,7 @@ export enum EventName { KeymapChange = 'keymapChange', NoteContentChange = 'noteContentChange', OcrServiceResourcesProcessed = 'ocrServiceResourcesProcessed', + NoteResourceIndexed = 'noteResourceIndexed', } export class EventManager { diff --git a/packages/lib/services/ResourceService.ts b/packages/lib/services/ResourceService.ts index 7668db7a971..1de05b1b770 100644 --- a/packages/lib/services/ResourceService.ts +++ b/packages/lib/services/ResourceService.ts @@ -9,6 +9,7 @@ import Resource from '../models/Resource'; import SearchEngine from './search/SearchEngine'; import ItemChangeUtils from './ItemChangeUtils'; import time from '../time'; +import eventManager, { EventName } from '../eventManager'; const { sprintf } = require('sprintf-js'); export default class ResourceService extends BaseService { @@ -107,6 +108,8 @@ export default class ResourceService extends BaseService { this.isIndexing_ = false; + eventManager.emit(EventName.NoteResourceIndexed); + this.logger().info('ResourceService::indexNoteResources: Completed'); }