25 lines
698 B
TypeScript
25 lines
698 B
TypeScript
import type { notesSourceValues } from '@/composables/useNotes'
|
|
|
|
interface Settings {
|
|
preferredNotesSource: notesSourceValues | null
|
|
}
|
|
|
|
export const preferredNotesSource = ref<notesSourceValues | null>(null)
|
|
|
|
const updateSettings = () => {
|
|
const settings: Settings = {
|
|
preferredNotesSource: preferredNotesSource.value
|
|
}
|
|
localStorage.setItem('settings', JSON.stringify(settings))
|
|
}
|
|
|
|
export const initializeSettings = () => {
|
|
watch([preferredNotesSource], () => updateSettings())
|
|
try {
|
|
const settings: Settings = JSON.parse(localStorage.getItem('settings') || '{}')
|
|
preferredNotesSource.value = settings.preferredNotesSource
|
|
} catch (error) {
|
|
console.error(error)
|
|
}
|
|
}
|