OverviewFilesCommitsIssuesDocsReleasesPeers

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

146 lines · javascript ref:
import {
  fork as o,
  call as e,
  takeLatest as i,
  takeLeading as a,
  select as r,
  takeEvery as t,
  getContext as p,
  put as d,
} from "redux-saga/effects"
import { safeCall as m, createSpawnRestarted as l } from "../lib"
import { uiLayoutSaga as s, userProfileSaga as y } from "../ui-desktop"
import { platformSaga as f } from "../platform"
import { identityLoggedOut as n, identitySaga as g } from "../identity"
import { desktopFileDownloadsSaga as c } from "../media/file/saga/desktop-file-downloads.saga"
import { desktopFileMediaManagerSaga as u } from "../media/file/saga/desktop-file-media-manager.saga"
import { networkSaga as I } from "../network"
import { statsSaga as T } from "../stats"
import { debugSaga as k } from "../debug"
import { PLATFORM_CONTEXT_KEY as D } from "../constants"
import {
  switchRoomSubmit as N,
  createRoomSubmit as R,
  roomCreateHandler as E,
  closeRoomSubmit as S,
  joinRoomSubmit as O,
  leaveRoomSubmit as L,
  roomLeaveHandler as w,
  leaveRoomSuccessEvent as A,
  roomLeaveSuccessSaga as U,
  setNotifications as x,
  dmReplySubmit as C,
  roomSaga as G,
  roomListSaga as _,
  getRoomLeavingId as b,
  forwardMessageEvt as h,
  chatForwardMessageHandler as H,
} from "../room"
import { sendChatMessageSubmit as P, updateChatMessageSubmit as Y } from "../chat"
import { clearAllFiles as B, clearOldFiles as W } from "../media/file"
import { taskErrorSaga as j } from "../error"
import { PREFERENCES as q, preferencesSaga as v, preferenceUpdateTask as z } from "../preferences"
import { APP_STATUS as F } from "./app.constants"
import {
  appRootFunctionalitySaga as J,
  appInitialLinkHandler as K,
  appInitialStartupHandler as M,
  currentRoomSaga as Q,
  appRoomListHandlerSaga as V,
  appRoomJoinSaga as X,
  appDmResponseSaga as Z,
  appRoomSwitchSaga as $,
  appRoomCloseSaga as oo,
  appLocaleSaga as eo,
  setAppNotificationsTypeSaga as io,
  appRoomNotificationsSaga as ao,
  toggleAppNotificationsAlertSaga as ro,
  appChatAddMessageSaga as to,
  appChatUpdateMessageSaga as po,
  appStateCleanup as mo,
} from "./app.saga"
import { toursSaga as lo } from "./saga/app-tours.saga"
import { desktopRoomNotificationsSaga as so } from "./saga/desktop-room-notifications.saga"
import { appErrorSaga as yo } from "./saga/app-error.saga"
import { appCallManagerSaga as fo, appRoomsPresencesSaga as no } from "./saga/app-call.saga"
import { forceUpdateHandlerSaga as go, systemUpdateHandlerSaga as co } from "./saga/app-update.saga"
import { appDesktopUnreadRoomsWatcherSaga as uo } from "./saga/app-desktop-unread-rooms-watcher.saga"
import { appDesktopRoomPairingUIResetSaga as Io } from "./saga/app-desktop-room-pairing-ui-reset.saga"
import { appClearAllFilesHandler as To, appClearOldFilesHandler as ko } from "./saga/app-files.saga"
import {
  setAppCurrentRoomId as Do,
  getAppCurrentRoomId as No,
  setAppLocale as Ro,
  setAppNotificationsType as Eo,
  toggleAppNotificationsAlert as So,
  getAppCurrentCallRoomId as Oo,
  setAppStatus as Lo,
} from "./app.reducer"
import { clearLocalStorage as wo } from "../lib/localStorage"
import { appDestructSaga as Ao } from "./saga/app-destruct.saga"
const Uo = l({ onError: j })
export function* appDesktopIdentityLoggedOutSaga() {
  yield a(n, function* () {
    try {
      ;(yield d(Lo(F.IDENTITY_SETUP)), yield wo(), yield z(q.LOGOUT_BANNER, !0))
      const { restart: o } = yield p(D)
      yield e(o, { platform: !1 })
    } catch (o) {
      yield j("identityLoggedOutHandler", o)
    }
  })
}
export function* appDesktopHandlerSaga() {
  ;(yield i(Do, Q),
    yield t(R, E),
    yield o(V),
    yield t(O, X),
    yield t(C, Z),
    yield i(N, $),
    yield a(L, function* () {
      const o = yield r(b),
        i = yield r(Oo)
      yield e(w, { roomId: o, currentCallRoomId: i })
    }),
    yield a(A, function* ({ payload: o }) {
      const e = yield r(No)
      yield U({ roomId: o, currentRoomId: e })
    }),
    yield t(S, oo),
    yield t(Ro, eo),
    yield i(Eo, io),
    yield i(x, ao),
    yield i(So, ro),
    yield a(P, to),
    yield t(Y, po),
    yield i(B, To),
    yield t(h, H),
    yield i(W, ko))
}
export function* desktopAppSaga() {
  const e = Date.now()
  ;(yield Uo(yo),
    yield Uo(co),
    yield Uo(go),
    yield Uo(Ao),
    yield o(J, {
      [F.LOADING]: [],
      [F.RUNNING]: [appDesktopHandlerSaga, fo, so, c, u, G, _, no, lo, K, uo, Io],
      [F.IDENTITY_SETUP]: [mo],
      [F.TEARDOWN]: [],
      [F.DESTRUCTING]: [],
      [F.CRITICAL_ERROR]: [],
    }),
    yield Uo(appDesktopIdentityLoggedOutSaga),
    yield Uo(s),
    yield m(M))
  const i = Date.now()
  ;(yield Uo(T, { startTime: e, startDoneTime: i }),
    yield Uo(v),
    yield Uo(f),
    yield Uo(g),
    yield Uo(I),
    yield Uo(y),
    yield Uo(k))
}