mirror of
https://github.com/comatory/fb2iCal
synced 2025-06-05 22:09:25 +02:00
feature: add Svelte framework to app, refactor tracking panel into Svelte component
This commit is contained in:
30
lib/frontend/stores/configStore.js
Normal file
30
lib/frontend/stores/configStore.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
const createConfigStore = () => {
|
||||
const state = JSON.parse(localStorage.getItem('fb-to-ical-config') || '{}')
|
||||
|
||||
const { subscribe, set, update } = writable(state)
|
||||
|
||||
const setValue = (key, value) => {
|
||||
update((prevState) => {
|
||||
const nextState = {
|
||||
...prevState,
|
||||
[key]: value,
|
||||
}
|
||||
|
||||
localStorage.setItem('fb-to-ical-config', JSON.stringify(nextState))
|
||||
|
||||
return nextState
|
||||
})
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
subscribe,
|
||||
set,
|
||||
update,
|
||||
setValue,
|
||||
}
|
||||
}
|
||||
|
||||
export default createConfigStore()
|
Reference in New Issue
Block a user