1
0
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:
Ondřej Synáček
2020-12-15 22:42:43 +01:00
parent b86402a7ff
commit 470184aec0
2 changed files with 13 additions and 42 deletions

View File

@ -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,
}
}