1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-26 18:58:21 +02:00

Desktop: Make OCR results available to search immediately after completion

This commit is contained in:
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(); await this.setupOcrService();
eventManager.on(EventName.OcrServiceResourcesProcessed, () => { eventManager.on(EventName.OcrServiceResourcesProcessed, async () => {
await ResourceService.instance().indexNoteResources();
});
eventManager.on(EventName.NoteResourceIndexed, async () => {
SearchEngine.instance().scheduleSyncTables(); SearchEngine.instance().scheduleSyncTables();
}); });

View File

@ -11,7 +11,7 @@
"electronRebuild": "gulp electronRebuild", "electronRebuild": "gulp electronRebuild",
"tsc": "tsc --project tsconfig.json", "tsc": "tsc --project tsconfig.json",
"watch": "tsc --watch --preserveWatchOutput --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": "jest",
"test-ui": "playwright test", "test-ui": "playwright test",
"test-ci": "yarn test && sh ./integration-tests/run-ci.sh", "test-ci": "yarn test && sh ./integration-tests/run-ci.sh",

View File

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

View File

@ -9,6 +9,7 @@ import Resource from '../models/Resource';
import SearchEngine from './search/SearchEngine'; import SearchEngine from './search/SearchEngine';
import ItemChangeUtils from './ItemChangeUtils'; import ItemChangeUtils from './ItemChangeUtils';
import time from '../time'; import time from '../time';
import eventManager, { EventName } from '../eventManager';
const { sprintf } = require('sprintf-js'); const { sprintf } = require('sprintf-js');
export default class ResourceService extends BaseService { export default class ResourceService extends BaseService {
@ -107,6 +108,8 @@ export default class ResourceService extends BaseService {
this.isIndexing_ = false; this.isIndexing_ = false;
eventManager.emit(EventName.NoteResourceIndexed);
this.logger().info('ResourceService::indexNoteResources: Completed'); this.logger().info('ResourceService::indexNoteResources: Completed');
} }