fix null filter bug

This commit is contained in:
Jonathan Jenne 2022-06-20 21:40:11 +02:00
parent 62950258b1
commit 476a4c4634
2 changed files with 7 additions and 6 deletions

View File

@ -50,9 +50,10 @@
}
function handleClearFilter(e) {
filter = null
shownNotes = notes
storage.saveFilter(null)
filter = ''
shownNotes = applyFilterSort(notes, '')
storage.saveFilter('')
}
function handleToggleDarkMode(e) {

View File

@ -3,10 +3,10 @@ export default class Storage {
this.prefix = "notesapp"
}
getFilter = () => this.#load('filter', null)
getFilter = () => this.#load('filter')
saveFilter = (filter) => this.#save('filter', filter)
getTheme = () => this.#load('theme', '')
getTheme = () => this.#load('theme')
saveTheme = (theme) => this.#save('theme', theme)
getNotes() {
@ -24,7 +24,7 @@ export default class Storage {
localStorage.setItem(`${this.prefix}-${key}`, value)
}
#load(key, defaultValue = null) {
#load(key, defaultValue = '') {
const value = localStorage.getItem(`${this.prefix}-${key}`) || defaultValue
console.log(`loading key '${key}' with value '${value}'`)
return value