Removed indexedNotes from stores

Since the components don't need to access it anymore
This commit is contained in:
Simon Cambier
2022-04-20 16:38:23 +02:00
parent 6b25d9a81f
commit 0d3286de04
2 changed files with 16 additions and 38 deletions

View File

@@ -1,36 +1,7 @@
import { get, writable } from 'svelte/store'
import type { IndexedNote } from './globals'
import { writable } from 'svelte/store'
import type OmnisearchPlugin from './main'
function createIndexedNotes() {
const { subscribe, set, update } = writable<Record<string, IndexedNote>>({})
return {
subscribe,
set,
add(note: IndexedNote) {
update(notes => {
notes[note.path] = note
return notes
})
},
remove(path: string) {
update(notes => {
delete notes[path]
return notes
})
},
get(path: string): IndexedNote | undefined {
return get(indexedNotes)[path]
},
}
}
/**
* A reference to the plugin instance
*/
export const plugin = writable<OmnisearchPlugin>()
/**
* The entire list of indexed notes, constantly kept up-to-date.
*/
export const indexedNotes = createIndexedNotes()