Skip to content

Commit

Permalink
Desktop: Make OCR results available to search immediately after compl…
Browse files Browse the repository at this point in the history
…etion
  • Loading branch information
laurent22 committed Feb 9, 2024
1 parent 35fe392 commit 6f0fd42
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/app-desktop/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
2 changes: 1 addition & 1 deletion packages/app-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/lib/eventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum EventName {
KeymapChange = 'keymapChange',
NoteContentChange = 'noteContentChange',
OcrServiceResourcesProcessed = 'ocrServiceResourcesProcessed',
NoteResourceIndexed = 'noteResourceIndexed',
}

export class EventManager {
Expand Down
3 changes: 3 additions & 0 deletions packages/lib/services/ResourceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -107,6 +108,8 @@ export default class ResourceService extends BaseService {

this.isIndexing_ = false;

eventManager.emit(EventName.NoteResourceIndexed);

this.logger().info('ResourceService::indexNoteResources: Completed');
}

Expand Down

0 comments on commit 6f0fd42

Please sign in to comment.