Skip to content

Commit

Permalink
#90 fixed file paths
Browse files Browse the repository at this point in the history
what a nasty, nasty bug :|
  • Loading branch information
scambier committed Sep 21, 2022
1 parent 60de958 commit 80ce347
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/search-history.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { searchIndexFilePath } from './globals'
import { historyFilePath } from './globals'

export let searchHistory: string[] = []

export async function loadSearchHistory(): Promise<void> {
if (await app.vault.adapter.exists(searchIndexFilePath)) {
if (await app.vault.adapter.exists(historyFilePath)) {
try {
searchHistory = JSON.parse(
await app.vault.adapter.read(searchIndexFilePath)
)
searchHistory = JSON.parse(await app.vault.adapter.read(historyFilePath))
// Keep the last 100 searches
searchHistory = searchHistory.slice(0, 100)
} catch (e) {
Expand All @@ -21,8 +19,5 @@ export async function loadSearchHistory(): Promise<void> {
}

export async function saveSearchHistory(): Promise<void> {
await app.vault.adapter.write(
searchIndexFilePath,
JSON.stringify(searchHistory)
)
await app.vault.adapter.write(historyFilePath, JSON.stringify(searchHistory))
}

0 comments on commit 80ce347

Please sign in to comment.