1
0
mirror of https://github.com/comatory/fb2iCal synced 2025-06-05 22:09:25 +02:00

feature: add UI for user approval of tracking

This commit is contained in:
Ondřej Synáček
2020-12-12 13:54:59 +01:00
parent 737620e2ca
commit a249a23ddd
4 changed files with 124 additions and 0 deletions

View File

@ -27,6 +27,21 @@ const getStorage = () => {
return storage
}
const getConfigStorage = () => {
if (!useStorage()) {
return null
}
const storage = localStorage.getItem('fb-to-ical-config')
if (!storage) {
localStorage.setItem('fb-to-ical-config', JSON.stringify({}))
return "{}"
}
return storage
}
const getStorageContents = (storage) => {
return JSON.parse(storage)
}
@ -37,6 +52,15 @@ const updateStorage = (storageContents) => {
localStorage.setItem('fb-to-ical-events', encodedStorage)
}
const updateConfigStorage = (storageContents, key, value) => {
const encodedStorage = JSON.stringify({
...storageContents,
[key]: value,
})
localStorage.setItem('fb-to-ical-config', encodedStorage)
}
const saveRecord = ({ id, link, createdAt, startTime, title }) => {
if (!useStorage()) {
return
@ -80,8 +104,10 @@ const deleteRecord = (id) => {
export {
migrateRecord,
getStorage,
getConfigStorage,
getStorageContents,
updateStorage,
updateConfigStorage,
saveRecord,
deleteRecord,
}