removed disabling option
This commit is contained in:
parent
f0c16d5905
commit
d85a132e50
|
@ -11,8 +11,6 @@ export const regexExtensions = /(?:^|\s)\.(\w+)/g
|
||||||
export const excerptBefore = 100
|
export const excerptBefore = 100
|
||||||
export const excerptAfter = 300
|
export const excerptAfter = 300
|
||||||
|
|
||||||
export const K_DISABLE_OMNISEARCH = 'locator-disabled'
|
|
||||||
|
|
||||||
export const eventBus = new EventBus()
|
export const eventBus = new EventBus()
|
||||||
|
|
||||||
export const EventNames = {
|
export const EventNames = {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import {
|
||||||
import type { LocatorSettings } from './settings/utils'
|
import type { LocatorSettings } from './settings/utils'
|
||||||
import { isCacheEnabled } from './settings/utils'
|
import { isCacheEnabled } from './settings/utils'
|
||||||
import { saveSettings } from './settings/utils'
|
import { saveSettings } from './settings/utils'
|
||||||
import { isPluginDisabled } from './settings/utils'
|
|
||||||
import {
|
import {
|
||||||
eventBus,
|
eventBus,
|
||||||
EventNames,
|
EventNames,
|
||||||
|
@ -70,11 +69,6 @@ export default class LocatorPlugin extends Plugin {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPluginDisabled(this.app)) {
|
|
||||||
console.debug('Plugin disabled')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await cleanOldCacheFiles(this.app)
|
await cleanOldCacheFiles(this.app)
|
||||||
await this.database.clearOldDatabases()
|
await this.database.clearOldDatabases()
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
// noinspection CssUnresolvedCustomProperty
|
// noinspection CssUnresolvedCustomProperty
|
||||||
import {
|
import { App, Plugin, PluginSettingTab, Setting } from 'obsidian'
|
||||||
App,
|
|
||||||
Plugin,
|
|
||||||
PluginSettingTab,
|
|
||||||
Setting,
|
|
||||||
} from 'obsidian'
|
|
||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
import { K_DISABLE_OMNISEARCH, RecencyCutoff } from '../globals'
|
import { RecencyCutoff } from '../globals'
|
||||||
import type LocatorPlugin from '../main'
|
import type LocatorPlugin from '../main'
|
||||||
import { enableVerboseLogging } from '../tools/utils'
|
import { enableVerboseLogging } from '../tools/utils'
|
||||||
import { injectSettingsIndexing } from './settings-indexing'
|
import { injectSettingsIndexing } from './settings-indexing'
|
||||||
|
@ -37,15 +32,9 @@ export class SettingsTab extends PluginSettingTab {
|
||||||
|
|
||||||
display(): void {
|
display(): void {
|
||||||
const { containerEl } = this
|
const { containerEl } = this
|
||||||
const database = this.plugin.database
|
|
||||||
|
|
||||||
containerEl.empty()
|
containerEl.empty()
|
||||||
|
|
||||||
if (this.app.loadLocalStorage(K_DISABLE_OMNISEARCH) == '1') {
|
|
||||||
const span = containerEl.createEl('span')
|
|
||||||
span.innerHTML = `<strong style="color: var(--text-accent)">⚠️ OMNISEARCH IS DISABLED ⚠️</strong>`
|
|
||||||
}
|
|
||||||
|
|
||||||
// Settings main title
|
// Settings main title
|
||||||
containerEl.createEl('h1', { text: 'Locator' })
|
containerEl.createEl('h1', { text: 'Locator' })
|
||||||
|
|
||||||
|
@ -154,9 +143,7 @@ export let settings: LocatorSettings
|
||||||
// return settings
|
// return settings
|
||||||
// }
|
// }
|
||||||
|
|
||||||
export async function loadSettings(
|
export async function loadSettings(plugin: Plugin): Promise<LocatorSettings> {
|
||||||
plugin: Plugin
|
|
||||||
): Promise<LocatorSettings> {
|
|
||||||
settings = Object.assign(
|
settings = Object.assign(
|
||||||
{},
|
{},
|
||||||
getDefaultSettings(plugin.app),
|
getDefaultSettings(plugin.app),
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
import { Notice, Setting } from 'obsidian'
|
import { Setting } from 'obsidian'
|
||||||
import type { LocatorSettings } from './utils'
|
|
||||||
import { isCacheEnabled } from './utils'
|
|
||||||
import { saveSettings } from './utils'
|
|
||||||
import { htmlDescription, isPluginDisabled, needsARestart } from './utils'
|
|
||||||
import type LocatorPlugin from 'src/main'
|
import type LocatorPlugin from 'src/main'
|
||||||
import { K_DISABLE_OMNISEARCH } from 'src/globals'
|
import type { LocatorSettings } from './utils'
|
||||||
|
import { htmlDescription, isCacheEnabled, needsARestart, saveSettings } from './utils'
|
||||||
|
|
||||||
export function injectSettingsDanger(
|
export function injectSettingsDanger(
|
||||||
plugin: LocatorPlugin,
|
plugin: LocatorPlugin,
|
||||||
|
@ -15,27 +12,6 @@ export function injectSettingsDanger(
|
||||||
|
|
||||||
new Setting(containerEl).setName('Danger Zone').setHeading()
|
new Setting(containerEl).setName('Danger Zone').setHeading()
|
||||||
|
|
||||||
// Disable Locator
|
|
||||||
const disableDesc = new DocumentFragment()
|
|
||||||
disableDesc.createSpan({}, span => {
|
|
||||||
span.innerHTML = `Disable Locator on this device only.<br>
|
|
||||||
${needsARestart}`
|
|
||||||
})
|
|
||||||
new Setting(containerEl)
|
|
||||||
.setName('Disable on this device')
|
|
||||||
.setDesc(disableDesc)
|
|
||||||
.addToggle(toggle =>
|
|
||||||
toggle.setValue(isPluginDisabled(plugin.app)).onChange(async v => {
|
|
||||||
if (v) {
|
|
||||||
plugin.app.saveLocalStorage(K_DISABLE_OMNISEARCH, '1')
|
|
||||||
new Notice('Locator - Disabled. Please restart Obsidian.')
|
|
||||||
} else {
|
|
||||||
plugin.app.saveLocalStorage(K_DISABLE_OMNISEARCH) // No value = unset
|
|
||||||
new Notice('Locator - Enabled. Please restart Obsidian.')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
|
|
||||||
// Force save cache
|
// Force save cache
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Force save the cache')
|
.setName('Force save the cache')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { App, Platform, Plugin } from 'obsidian'
|
import { App, Platform, Plugin } from 'obsidian'
|
||||||
import { K_DISABLE_OMNISEARCH, RecencyCutoff } from 'src/globals'
|
import { RecencyCutoff } from 'src/globals'
|
||||||
import { settings } from '.'
|
import { settings } from '.'
|
||||||
|
|
||||||
export function htmlDescription(innerHTML: string): DocumentFragment {
|
export function htmlDescription(innerHTML: string): DocumentFragment {
|
||||||
|
@ -20,9 +20,6 @@ export interface WeightingSettings {
|
||||||
weightH3: number
|
weightH3: number
|
||||||
weightUnmarkedTags: number
|
weightUnmarkedTags: number
|
||||||
}
|
}
|
||||||
export function isPluginDisabled(app: App): boolean {
|
|
||||||
return app.loadLocalStorage(K_DISABLE_OMNISEARCH) === '1'
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function saveSettings(plugin: Plugin): Promise<void> {
|
export async function saveSettings(plugin: Plugin): Promise<void> {
|
||||||
await plugin.saveData(settings)
|
await plugin.saveData(settings)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user