import { call as e, getContext as t } from "redux-saga/effects"
import { LOCAL_STORAGE_CONTEXT_KEY as o } from "../constants"
import { taskErrorSaga as r } from "../error"
export function* openLocalStorage() {
try {
const { open: r } = yield t(o)
return (yield e(r), !0)
} catch (e) {
return (yield r("local storage: can't open", e), !1)
}
}
export function* getLocalStorage(c) {
let a
try {
const { getItem: r } = yield t(o)
a = yield e(r, c)
} catch (e) {
yield r(`local storage: can't get "${c}"`, e)
}
return a
}
export function* setLocalStorage(c, a) {
try {
const { setItem: r } = yield t(o)
yield e(r, c, a)
} catch (e) {
yield r(`local storage: can't set "${c}"`, e)
}
}
export function* removeLocalStorage(c) {
try {
const { removeItem: r } = yield t(o)
yield e(r, c)
} catch (e) {
yield r(`local storage: can't remove "${c}"`, e)
}
}
export function* clearLocalStorage() {
try {
const { clear: r } = yield t(o)
yield e(r)
} catch (e) {
yield r("local storage: can't clear local storage", e)
}
}