Disabling PDF indexing on mobile to avoid a crash

This commit is contained in:
Simon Cambier
2022-10-13 08:36:35 +02:00
parent 342cdabdd9
commit 0381d1918b

View File

@@ -1,4 +1,10 @@
import { Plugin, PluginSettingTab, Setting, SliderComponent } from 'obsidian' import {
Platform,
Plugin,
PluginSettingTab,
Setting,
SliderComponent,
} from 'obsidian'
import { writable } from 'svelte/store' import { writable } from 'svelte/store'
import { notesCacheFilePath, minisearchCacheFilePath } from './globals' import { notesCacheFilePath, minisearchCacheFilePath } from './globals'
import type OmnisearchPlugin from './main' import type OmnisearchPlugin from './main'
@@ -167,24 +173,25 @@ export class SettingsTab extends PluginSettingTab {
}) })
) )
// PDF Indexing // PDF Indexing - not available on mobile
const indexPDFsDesc = new DocumentFragment() if (!Platform.isMobileApp) {
indexPDFsDesc.createSpan({}, span => { const indexPDFsDesc = new DocumentFragment()
span.innerHTML = `Omnisearch will include PDFs in search results. indexPDFsDesc.createSpan({}, span => {
span.innerHTML = `Omnisearch will include PDFs in search results.
This feature is currently a work-in-progress, please report slowdowns or issues that you might experience.<br> This feature is currently a work-in-progress, please report slowdowns or issues that you might experience.<br>
Each PDF can take a few seconds to be indexed, so it may not appear immediately in search results.<br> Each PDF can take a few seconds to be indexed, so it may not appear immediately in search results.<br>
<strong style="color: var(--text-accent)">Needs a restart to fully take effect.</strong>` <strong style="color: var(--text-accent)">Needs a restart to fully take effect.</strong>`
}) })
new Setting(containerEl) new Setting(containerEl)
.setName('BETA - PDF Indexing') .setName('BETA - PDF Indexing')
.setDesc(indexPDFsDesc) .setDesc(indexPDFsDesc)
.addToggle(toggle => .addToggle(toggle =>
toggle.setValue(settings.PDFIndexing).onChange(async v => { toggle.setValue(settings.PDFIndexing).onChange(async v => {
settings.PDFIndexing = v settings.PDFIndexing = v
await saveSettings(this.plugin) await saveSettings(this.plugin)
}) })
) )
}
// #endregion Behavior // #endregion Behavior
// #region User Interface // #region User Interface
@@ -330,7 +337,9 @@ export const DEFAULT_SETTINGS: OmnisearchSettings = {
ignoreDiacritics: true, ignoreDiacritics: true,
indexedFileTypes: [] as string[], indexedFileTypes: [] as string[],
PDFIndexing: false, PDFIndexing: false,
backgroundProcesses: Math.max(1, Math.floor(require('os').cpus().length / 2)), backgroundProcesses: Platform.isMobileApp
? 0
: Math.max(1, Math.floor(require('os').cpus().length / 2)),
showIndexingNotices: false, showIndexingNotices: false,
showShortName: false, showShortName: false,