Moved recency setting

This commit is contained in:
Simon Cambier
2025-02-17 07:47:09 +01:00
parent 0be76a4804
commit 3d7932e580
3 changed files with 41 additions and 36 deletions

View File

@@ -57,11 +57,17 @@ export class SettingsTab extends PluginSettingTab {
`
injectSettingsIndexing(this.plugin, settings, containerEl)
containerEl.createEl('hr')
injectSettingsBehavior(this.plugin, settings, containerEl)
containerEl.createEl('hr')
injectSettingsUserInterface(this.plugin, settings, containerEl)
containerEl.createEl('hr')
injectSettingsWeighting(this.plugin, settings, containerEl, this.display)
containerEl.createEl('hr')
injectSettingsHttp(this.plugin, settings, containerEl)
containerEl.createEl('hr')
injectSettingsDanger(this.plugin, settings, containerEl)
containerEl.createEl('hr')
//#region Debugging

View File

@@ -3,7 +3,6 @@ import type { OmnisearchSettings } from './utils'
import { saveSettings } from './utils'
import { htmlDescription, needsARestart } from './utils'
import type OmnisearchPlugin from 'src/main'
import { RecencyCutoff } from 'src/globals'
import { getCtrlKeyLabel } from 'src/tools/utils'
export function injectSettingsBehavior(
@@ -53,26 +52,6 @@ export function injectSettingsBehavior(
})
)
new Setting(containerEl)
.setName('Recency boost (experimental)')
.setDesc(
'Files that have been modified more recently than [selected cutoff] are given a higher rank.'
)
.addDropdown(dropdown =>
dropdown
.addOptions({
[RecencyCutoff.Disabled]: 'Disabled',
[RecencyCutoff.Day]: '24 hours',
[RecencyCutoff.Week]: '7 days',
[RecencyCutoff.Month]: '30 days',
})
.setValue(settings.recencyBoost)
.onChange(async v => {
settings.recencyBoost = v as RecencyCutoff
await saveSettings(plugin)
})
)
// Downranked files
new Setting(containerEl)
.setName('Folders to downrank in search results')

View File

@@ -1,11 +1,10 @@
import { Setting, SliderComponent } from 'obsidian'
import {
getDefaultSettings,
} from 'src/settings'
import { getDefaultSettings } from 'src/settings'
import type { OmnisearchSettings } from './utils'
import { saveSettings } from './utils'
import type { WeightingSettings } from './utils'
import type OmnisearchPlugin from 'src/main'
import { RecencyCutoff } from 'src/globals'
export function injectSettingsWeighting(
plugin: OmnisearchPlugin,
@@ -64,10 +63,11 @@ export function injectSettingsWeighting(
for (let i = 0; i < settings.weightCustomProperties.length; i++) {
const item = settings.weightCustomProperties[i]
new Setting(containerEl)
.setName((i + 1).toString() + '.')
const el = new Setting(containerEl).setName((i + 1).toString() + '.')
el.settingEl.style.paddingLeft = '2em'
// TODO: add autocompletion from app.metadataCache.getAllPropertyInfos()
.addText(text => {
el.addText(text => {
text
.setPlaceholder('Property name')
.setValue(item.name)
@@ -104,4 +104,24 @@ export function injectSettingsWeighting(
refreshDisplay()
})
})
new Setting(containerEl)
.setName('Recency boost (experimental)')
.setDesc(
'Files that have been modified more recently than [selected cutoff] are given a higher rank.'
)
.addDropdown(dropdown =>
dropdown
.addOptions({
[RecencyCutoff.Disabled]: 'Disabled',
[RecencyCutoff.Day]: '24 hours',
[RecencyCutoff.Week]: '7 days',
[RecencyCutoff.Month]: '30 days',
})
.setValue(settings.recencyBoost)
.onChange(async v => {
settings.recencyBoost = v as RecencyCutoff
await saveSettings(plugin)
})
)
}