mirror of
https://github.com/comatory/fb2iCal
synced 2025-06-05 22:09:25 +02:00
fixup! feature: update event store contents from existing code
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { writable } from 'svelte/store'
|
||||
|
||||
import { STORAGE_KEYS } from '../services/storageListener'
|
||||
import { migrateRecord, sortRecords } from '../../static/app/storage'
|
||||
import { migrateRecord, sortRecord } from '../utils'
|
||||
|
||||
const createEventStore = () => {
|
||||
const state = JSON.parse(localStorage.getItem(STORAGE_KEYS.EVENTS) || '[]')
|
||||
@ -23,6 +23,16 @@ const createEventStore = () => {
|
||||
]))
|
||||
}
|
||||
|
||||
const clearCalculation = (id) => {
|
||||
const calculationIndex = state.findIndex((event) => event.id === id)
|
||||
|
||||
if (calculationIndex === -1) {
|
||||
return
|
||||
}
|
||||
|
||||
set(state.splice(calculationIndex, 1))
|
||||
}
|
||||
|
||||
const getState = () => state
|
||||
|
||||
return {
|
||||
@ -31,6 +41,7 @@ const createEventStore = () => {
|
||||
set,
|
||||
update,
|
||||
setCalculation,
|
||||
clearCalculation,
|
||||
getState,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user