OverviewFilesCommitsIssuesDocsReleasesPeers

keet-deobfuscated / @holepunchto / keet-store / store / app / saga / app-destruct.saga.js

45 lines · javascript ref:
import {
  call as e,
  getContext as t,
  put as o,
  select as r,
  takeLatest as i,
} from "redux-saga/effects"
import { getAppStatus as c, selfDestruct as a, setAppStatus as l } from "../app.reducer"
import { APP_STATUS as d, SELF_DESTRUCT_CONFIRMATION as s } from "../app.constants"
import { getPearBackend as y } from "../../../backend"
import { clearLocalStorage as n, setLocalStorage as p } from "../../lib/localStorage"
import {
  APP_CONTEXT_KEY as f,
  ENV_CONTEXT_KEY as m,
  LOCAL_STORAGE_CONTEXT_KEY as u,
  PLATFORM_CONTEXT_KEY as R,
} from "../../constants"
import { taskErrorSaga as S } from "../../error"
export function* appDestructSaga() {
  yield i(a, function* () {
    const i = yield r(c)
    try {
      yield o(l(d.DESTRUCTING))
      const r = y()
      yield e([r, r.selfDestruct], { confirm: s })
      const { isMobile: i } = yield t(m)
      try {
        if ((yield n(), i)) {
          try {
            const { keys: o } = yield t(u)
            yield e(p, o.IS_RN_REBOOT, "true")
          } catch (e) {}
          const { safeReload: o } = yield t(f)
          yield e(o)
        } else {
          const { restart: o } = yield t(R)
          yield e(o, { needToReloadIdentity: !0 })
        }
      } catch (e) {}
    } catch (e) {
      ;(yield S("appDestructSaga", e), yield o(l(i)))
    }
  })
}