OverviewFilesCommitsIssuesDocsReleasesPeers

keet-deobfuscated / @holepunchto / keet-store / store / ui-mobile / ui.saga.js

153 lines · javascript ref:
import {
  call as i,
  getContext as o,
  put as e,
  select as t,
  take as a,
  takeEvery as r,
  takeLatest as n,
  fork as l,
  takeLeading as d,
} from "redux-saga/effects"
import {
  getUIAppModal as y,
  getUIAppNavigatorCurrentRoute as u,
  getUIAppShowModal as s,
  getUIWalkthroughTooltip as m,
  setUIAppState as f,
  setUICloseAppModal as c,
  setUICloseWalkthroughTooltip as p,
  setUIShowAppModal as g,
  setUIShowStats as S,
} from "./ui.reducer"
import {
  uiBatchJoinRoom as N,
  uiClearFileCache as v,
  uiCloseBottomSheet as E,
  uiCopyChatMessage as R,
  uiCopyMessageLink as h,
} from "./ui.action"
import {
  navigateAfterDmReply as x,
  navigateBackSaga as M,
  uiBatchJoinRoomHandler as W,
  uiJoinRoomHandler as C,
  uiRoomPairingNotificationSaga as H,
} from "./ui-room.saga"
import { APP_CONTEXT_KEY as O } from "../constants"
import { APP_STATUS as T, getAppCurrentRoomId as F, setAppInitialStatus as A } from "../app"
import {
  clearPairingRoom as I,
  getDmRequestSuccess as U,
  setDmRequestSuccess as b,
  setPairingRoom as D,
  joinRoomSubmit as V,
  setDmReplySuccess as _,
} from "../room"
import { memberRemoveSuccess as q } from "../member"
import { taskErrorSaga as w } from "../error"
import {
  clearFileCacheSaga as G,
  copyChatMessageSaga as L,
  copyMessageLinkSaga as k,
} from "./ui-chat.saga"
import { watchNavigation as K } from "./ui-navigation.saga"
import {
  getMyIdentity as Y,
  IDENTITY_USERNAME_SAVE_STATUS as j,
  resetUsernameReservationInfo as z,
  updateUsernameReservationInfo as B,
} from "../identity"
import { userSuccessNotification as J } from "../notification"
import { UI_APP_STATE as P } from "./ui.constants"
import {
  getChatMessageCount as Q,
  getChatMessagesInView as X,
  setChatListViewMode as Z,
  VIEW_MODE as $,
} from "../chat"
import { uiSetWebrtcStatsHandler as ii } from "./ui-call.utils"
export function* uiWaitForModalsToClose() {
  for (; yield t(s); ) yield a(c)
}
export function* uiWaitForToolTip() {
  for (; yield t(m); ) yield a(p)
}
export function* uiWaitToShowHome() {
  try {
    const { navigationConstants: i } = yield o(O)
    for (;;) if ((yield a("*"), (yield t(u)) === i.SCREEN_HOME)) return
  } catch (i) {
    yield w("uiWaitToShowHome", i)
  }
}
export function* uiWaitForNavigation() {
  try {
    const { navigationHelpers: e } = yield o(O)
    if (yield i(e.hasNavigator)) return
    for (;;) if ((yield a("*"), yield i(e.hasNavigator))) return
  } catch (i) {
    yield w("uiWaitForNavigation", i)
  }
}
export function* uiWaitForAppRunning() {
  try {
    for (;;) {
      const {
        payload: { status: i },
      } = yield a(A)
      if (i === T.RUNNING) return
    }
  } catch (i) {
    yield w("uiWaitForAppRunning", i)
  }
}
export function* uiModalOpenSaga() {
  const { navigationConstants: i, navigationHelpers: e } = yield o(O),
    a = yield t(y)
  "queue" in a && 1 === a.queue.length && e.navigate(i.SCREEN_MODAL)
}
export function* uiModalCloseSaga() {
  const { navigationHelpers: i } = yield o(O)
  ;(yield t(s)) || i.back()
}
function* oi() {
  ;(yield t(U)) && (yield e(E()))
}
let ei = j.UNKNOWN
function* ti() {
  const i = yield t(Y)
  if (i.createUsernameStatus === j.RESERVED && ei === j.RESERVING) {
    const { localeManager: i } = yield o(O),
      { account: t } = i.getStrings()
    ;(yield e(J({ message: t.usernameReservedMsg })), yield e(z()))
  }
  ei = i.createUsernameStatus
}
function* ai(i) {
  if (!(yield t(F))) return
  const { payload: o } = i
  if (o === P.ACTIVE) {
    const i = yield t(Q),
      { bottom: o } = yield t(X)
    o === i - 1 || (yield e(Z($.HISTORY)))
  } else yield e(Z($.ON_HOLD))
}
export function* uiSaga() {
  ;(yield l(K),
    yield d(q, M),
    yield d(_, x),
    yield n(g, uiModalOpenSaga),
    yield n(c, uiModalCloseSaga),
    yield n(V, C),
    yield n(N, W),
    yield r([D, I], H),
    yield n(R, L),
    yield n(h, k),
    yield n(v, G),
    yield d(b, oi),
    yield n(B, ti),
    yield n(f, ai),
    yield n(S, ii))
}