Cleaned global app warnings

This commit is contained in:
Simon Cambier
2024-05-18 09:52:28 +02:00
parent 82fe4c7eb8
commit 5010a47466
10 changed files with 46 additions and 30 deletions

View File

@@ -9,8 +9,12 @@ import { cacheManager } from '../cache-manager'
import { sortBy } from 'lodash-es'
import { getMatches, stringsToRegex } from 'src/tools/text-processing'
import { tokenizeForIndexing, tokenizeForSearch } from './tokenizer'
import { getObsidianApp } from '../stores/obsidian-app'
export class Omnisearch {
app = getObsidianApp()
public static readonly options: Options<IndexedDocument> = {
tokenize: tokenizeForIndexing,
extractField: (doc, fieldName) => {
@@ -244,16 +248,16 @@ export class Omnisearch {
results = results.filter(
result =>
!(
app.metadataCache.isUserIgnored &&
app.metadataCache.isUserIgnored(result.id)
this.app.metadataCache.isUserIgnored &&
this.app.metadataCache.isUserIgnored(result.id)
)
)
} else {
// Just downrank them
results.forEach(result => {
if (
app.metadataCache.isUserIgnored &&
app.metadataCache.isUserIgnored(result.id)
this.app.metadataCache.isUserIgnored &&
this.app.metadataCache.isUserIgnored(result.id)
) {
result.score /= 10
}
@@ -293,7 +297,7 @@ export class Omnisearch {
}
// Boost custom properties
const metadata = app.metadataCache.getCache(path)
const metadata = this.app.metadataCache.getCache(path)
if (metadata) {
for (const { name, weight } of settings.weightCustomProperties) {
const values = metadata?.frontmatter?.[name]