#57: Fix for mobile
This commit is contained in:
13
src/main.ts
13
src/main.ts
@@ -9,14 +9,23 @@ import {
|
|||||||
import { OmnisearchInFileModal, OmnisearchVaultModal } from './modals'
|
import { OmnisearchInFileModal, OmnisearchVaultModal } from './modals'
|
||||||
import { loadSettings, settings, SettingsTab } from './settings'
|
import { loadSettings, settings, SettingsTab } from './settings'
|
||||||
|
|
||||||
const mainWindow = require('electron').remote.getCurrentWindow()
|
let mainWindow: { on: any; off: any } | null = null
|
||||||
|
try {
|
||||||
|
mainWindow = require('electron').remote.getCurrentWindow()
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
console.log("Can't load electron, mobile platform")
|
||||||
|
}
|
||||||
|
|
||||||
const onBlur = (): void => {
|
const onBlur = (): void => {
|
||||||
reindexNotes()
|
reindexNotes()
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class OmnisearchPlugin extends Plugin {
|
export default class OmnisearchPlugin extends Plugin {
|
||||||
async onload(): Promise<void> {
|
async onload(): Promise<void> {
|
||||||
|
if (mainWindow) {
|
||||||
mainWindow.on('blur', onBlur)
|
mainWindow.on('blur', onBlur)
|
||||||
|
}
|
||||||
|
|
||||||
await loadSettings(this)
|
await loadSettings(this)
|
||||||
this.addSettingTab(new SettingsTab(this))
|
this.addSettingTab(new SettingsTab(this))
|
||||||
@@ -75,6 +84,8 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onunload(): void {
|
onunload(): void {
|
||||||
|
if (mainWindow) {
|
||||||
mainWindow.off('blur', onBlur)
|
mainWindow.off('blur', onBlur)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -53,16 +53,24 @@ export class SettingsTab extends PluginSettingTab {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
// Index in real-time
|
// Index in real-time, desktop only
|
||||||
|
if (require('electron')) {
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Reindex in real-time')
|
.setName('Reindex in real-time')
|
||||||
.setDesc('By default, notes a reindexed when Obsidian focus is lost. Enable this to reindex in real-time. May affect performances.')
|
.setDesc(
|
||||||
|
'By default, notes a reindexed when Obsidian focus is lost. Enable this to reindex in real-time. May affect performances.',
|
||||||
|
)
|
||||||
.addToggle(toggle =>
|
.addToggle(toggle =>
|
||||||
toggle.setValue(settings.reindexInRealTime).onChange(async v => {
|
toggle.setValue(settings.reindexInRealTime).onChange(async v => {
|
||||||
settings.reindexInRealTime = v
|
settings.reindexInRealTime = v
|
||||||
await saveSettings(this.plugin)
|
await saveSettings(this.plugin)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// No real time indexing on mobile
|
||||||
|
settings.reindexInRealTime = false
|
||||||
|
}
|
||||||
|
|
||||||
new Setting(containerEl).setName('Results weighting').setHeading()
|
new Setting(containerEl).setName('Results weighting').setHeading()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user