Desktop: Make OCR results available to search immediately after completion

pull/9917/head
Laurent Cozic 2024-02-09 11:55:29 +00:00
parent 35fe392058
commit 6f0fd4219e
4 changed files with 10 additions and 2 deletions

View File

@ -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();
});

View File

@ -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",

View File

@ -17,6 +17,7 @@ export enum EventName {
KeymapChange = 'keymapChange',
NoteContentChange = 'noteContentChange',
OcrServiceResourcesProcessed = 'ocrServiceResourcesProcessed',
NoteResourceIndexed = 'noteResourceIndexed',
}
export class EventManager {

View File

@ -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');
}