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 excerptAfter = 300
 | 
			
		||||
 | 
			
		||||
export const K_DISABLE_OMNISEARCH = 'locator-disabled'
 | 
			
		||||
 | 
			
		||||
export const eventBus = new EventBus()
 | 
			
		||||
 | 
			
		||||
export const EventNames = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,6 @@ import {
 | 
			
		|||
import type { LocatorSettings } from './settings/utils'
 | 
			
		||||
import { isCacheEnabled } from './settings/utils'
 | 
			
		||||
import { saveSettings } from './settings/utils'
 | 
			
		||||
import { isPluginDisabled } from './settings/utils'
 | 
			
		||||
import {
 | 
			
		||||
  eventBus,
 | 
			
		||||
  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 this.database.clearOldDatabases()
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,7 @@
 | 
			
		|||
// noinspection CssUnresolvedCustomProperty
 | 
			
		||||
import {
 | 
			
		||||
  App,
 | 
			
		||||
  Plugin,
 | 
			
		||||
  PluginSettingTab,
 | 
			
		||||
  Setting,
 | 
			
		||||
} from 'obsidian'
 | 
			
		||||
import { App, Plugin, PluginSettingTab, Setting } from 'obsidian'
 | 
			
		||||
import { writable } from 'svelte/store'
 | 
			
		||||
import { K_DISABLE_OMNISEARCH, RecencyCutoff } from '../globals'
 | 
			
		||||
import { RecencyCutoff } from '../globals'
 | 
			
		||||
import type LocatorPlugin from '../main'
 | 
			
		||||
import { enableVerboseLogging } from '../tools/utils'
 | 
			
		||||
import { injectSettingsIndexing } from './settings-indexing'
 | 
			
		||||
| 
						 | 
				
			
			@ -37,15 +32,9 @@ export class SettingsTab extends PluginSettingTab {
 | 
			
		|||
 | 
			
		||||
  display(): void {
 | 
			
		||||
    const { containerEl } = this
 | 
			
		||||
    const database = this.plugin.database
 | 
			
		||||
 | 
			
		||||
    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
 | 
			
		||||
    containerEl.createEl('h1', { text: 'Locator' })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -154,9 +143,7 @@ export let settings: LocatorSettings
 | 
			
		|||
//   return settings
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
export async function loadSettings(
 | 
			
		||||
  plugin: Plugin
 | 
			
		||||
): Promise<LocatorSettings> {
 | 
			
		||||
export async function loadSettings(plugin: Plugin): Promise<LocatorSettings> {
 | 
			
		||||
  settings = Object.assign(
 | 
			
		||||
    {},
 | 
			
		||||
    getDefaultSettings(plugin.app),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,7 @@
 | 
			
		|||
import { Notice, Setting } from 'obsidian'
 | 
			
		||||
import type { LocatorSettings } from './utils'
 | 
			
		||||
import { isCacheEnabled } from './utils'
 | 
			
		||||
import { saveSettings } from './utils'
 | 
			
		||||
import { htmlDescription, isPluginDisabled, needsARestart } from './utils'
 | 
			
		||||
import { Setting } from 'obsidian'
 | 
			
		||||
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(
 | 
			
		||||
  plugin: LocatorPlugin,
 | 
			
		||||
| 
						 | 
				
			
			@ -15,27 +12,6 @@ export function injectSettingsDanger(
 | 
			
		|||
 | 
			
		||||
  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
 | 
			
		||||
  new Setting(containerEl)
 | 
			
		||||
    .setName('Force save the cache')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
import { App, Platform, Plugin } from 'obsidian'
 | 
			
		||||
import { K_DISABLE_OMNISEARCH, RecencyCutoff } from 'src/globals'
 | 
			
		||||
import { RecencyCutoff } from 'src/globals'
 | 
			
		||||
import { settings } from '.'
 | 
			
		||||
 | 
			
		||||
export function htmlDescription(innerHTML: string): DocumentFragment {
 | 
			
		||||
| 
						 | 
				
			
			@ -20,9 +20,6 @@ export interface WeightingSettings {
 | 
			
		|||
  weightH3: number
 | 
			
		||||
  weightUnmarkedTags: number
 | 
			
		||||
}
 | 
			
		||||
export function isPluginDisabled(app: App): boolean {
 | 
			
		||||
  return app.loadLocalStorage(K_DISABLE_OMNISEARCH) === '1'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function saveSettings(plugin: Plugin): Promise<void> {
 | 
			
		||||
  await plugin.saveData(settings)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user