From c0061444885539e598907a45a0dc7e5c7c84c747 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Fri, 7 Jun 2024 12:32:03 +0200 Subject: [PATCH 1/3] 1.24.0-beta.1 manifest --- manifest-beta.json | 2 +- versions.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/manifest-beta.json b/manifest-beta.json index 14a7256..a6b7093 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "omnisearch", "name": "Omnisearch", - "version": "1.23.0", + "version": "1.24.0-beta.1", "minAppVersion": "1.3.0", "description": "A search engine that just works", "author": "Simon Cambier", diff --git a/versions.json b/versions.json index 94aa108..6fa25e4 100644 --- a/versions.json +++ b/versions.json @@ -141,5 +141,6 @@ "1.23.0-beta.3": "1.3.0", "1.23.0-beta.4": "1.3.0", "1.23.0-beta.5": "1.3.0", - "1.23.0": "1.3.0" + "1.23.0": "1.3.0", + "1.24.0-beta.1": "1.3.0" } \ No newline at end of file From 59cfd877ae6a6325bd5efcf441e61339cbb46397 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Fri, 7 Jun 2024 12:30:00 +0200 Subject: [PATCH 2/3] Don't needlessly refresh the live cache --- src/main.ts | 12 +++++++++--- src/notes-indexer.ts | 6 ++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 4924dd0..4817945 100644 --- a/src/main.ts +++ b/src/main.ts @@ -42,6 +42,7 @@ export default class OmnisearchPlugin extends Plugin { public readonly searchEngine = new SearchEngine(this) private ribbonButton?: HTMLElement + private refreshIndexCallback?: () => void constructor(app: App, manifest: PluginManifest) { super(app, manifest) @@ -106,7 +107,6 @@ export default class OmnisearchPlugin extends Plugin { this.app.vault.on('create', file => { if (this.notesIndexer.isFileIndexable(file.path)) { logDebug('Indexing new file', file.path) - // await cacheManager.addToLiveCache(file.path) searchEngine.addFromPaths([file.path]) } }) @@ -121,8 +121,6 @@ export default class OmnisearchPlugin extends Plugin { this.registerEvent( this.app.vault.on('modify', async file => { if (this.notesIndexer.isFileIndexable(file.path)) { - logDebug('Updating file', file.path) - await this.cacheManager.addToLiveCache(file.path) this.notesIndexer.flagNoteForReindex(file) } }) @@ -139,6 +137,10 @@ export default class OmnisearchPlugin extends Plugin { }) ) + this.refreshIndexCallback = this.notesIndexer.refreshIndex.bind(this.notesIndexer) + addEventListener('blur', this.refreshIndexCallback) + removeEventListener + await this.executeFirstLaunchTasks() await this.populateIndex() @@ -165,6 +167,10 @@ export default class OmnisearchPlugin extends Plugin { // @ts-ignore delete globalThis['omnisearch'] + if (this.refreshIndexCallback) { + removeEventListener('blur', this.refreshIndexCallback) + } + // Clear cache when disabling Omnisearch if (process.env.NODE_ENV === 'production') { await this.database.clearCache() diff --git a/src/notes-indexer.ts b/src/notes-indexer.ts index 611051b..89f51f7 100644 --- a/src/notes-indexer.ts +++ b/src/notes-indexer.ts @@ -7,6 +7,7 @@ import { isFileFromDataloomPlugin, isFileImage, isFilePDF, + logDebug, } from './tools/utils' export class NotesIndexer { @@ -23,6 +24,11 @@ export class NotesIndexer { } public async refreshIndex(): Promise { + for (const file of this.notesToReindex) { + logDebug('Updating file', file.path) + await this.plugin.cacheManager.addToLiveCache(file.path) + } + const paths = [...this.notesToReindex].map(n => n.path) if (paths.length) { this.plugin.searchEngine.removeFromPaths(paths) From f6b63537c237d1119f8665e5b12ea6a17b3d447e Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Tue, 11 Jun 2024 07:05:10 +0200 Subject: [PATCH 3/3] 1.23.1 --- manifest.json | 2 +- package.json | 2 +- versions.json | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index fc6efcb..c635ee4 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "omnisearch", "name": "Omnisearch", - "version": "1.23.0", + "version": "1.23.1", "minAppVersion": "1.3.0", "description": "A search engine that just works", "author": "Simon Cambier", diff --git a/package.json b/package.json index 73e3e86..382d86a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scambier.obsidian-search", - "version": "1.23.0", + "version": "1.23.1", "description": "A search engine for Obsidian", "main": "dist/main.js", "scripts": { diff --git a/versions.json b/versions.json index 6fa25e4..48ab2f7 100644 --- a/versions.json +++ b/versions.json @@ -142,5 +142,6 @@ "1.23.0-beta.4": "1.3.0", "1.23.0-beta.5": "1.3.0", "1.23.0": "1.3.0", - "1.24.0-beta.1": "1.3.0" + "1.24.0-beta.1": "1.3.0", + "1.23.1": "1.3.0" } \ No newline at end of file