OverviewFilesCommitsIssuesDocsReleasesPeers

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

159 lines · javascript ref:
import {
  put as i,
  takeEvery as e,
  select as o,
  fork as l,
  all as d,
  takeLatest as t,
  take as r,
} from "redux-saga/effects"
import {
  callCancel as y,
  callLeave as c,
  callJoinedEvt as n,
  callJoinDMIncoming as m,
  openCallSettings as a,
} from "../call/call.action"
import { getCallStatus as f, isCallJoinedMode as u } from "../call/call.reducer"
import {
  getAppCurrentCallRoomId as p,
  getAppCurrentRoomId as s,
  setAppCurrentRoomId as E,
  setAppStatus as I,
  getAppStatus as h,
  setAppInitialStatus as N,
  hasAppCurrentRoomCallMatch as S,
} from "../app/app.reducer"
import { APP_STATUS as O } from "../app/app.constants"
import {
  reportChatMessageSuccess as R,
  toggleChatSearching as T,
  getChatSearchLive as D,
  getChatListViewPaused as P,
  setChatListViewPaused as _,
} from "../chat"
import {
  getUILayoutType as M,
  getUIRoomListTab as U,
  resetUIPanels as b,
  setRoomListTab as g,
  setUIIncomingDmCallTransition as C,
  getUIIncomingDmCallTransition as Y,
  setUILayoutType as j,
  setUIPanels as v,
  getUICallExpanded as x,
  closeUIPanel as G,
  getUIPanelState as L,
  setAppActive as Q,
} from "./ui.reducer"
import { memberMuteToggleSuccess as V, memberRemoveSuccess as k } from "../member/member.reducer"
import { appActiveSaga as w } from "./ui-app-active.saga"
import {
  setSyncDeviceSeedId as A,
  addIdentityInvitedDevice as F,
} from "../identity/identity.reducer"
import { LAYOUT_TYPE as J, ROOM_LIST_TAB as q, UI_PANEL as z } from "./ui.constants"
import {
  clearPairingRoom as B,
  getRoomPairingIdActive as H,
  setRoomPairingActive as K,
} from "../room/joint/room-joint.reducer"
import {
  setUIRemoveMemberModal as W,
  setUIBlockMemberModal as X,
  setUIMuteMemberToggleModal as Z,
} from "./ui-modal.reducer"
import { uiRoomInfoSectionSaga as $ } from "./ui-room-info.saga"
import { getDmActiveId as ii, setDmActiveId as ei } from "../room"
import { callJoinCmd as oi } from "../call/call-status.action"
import { getErrorFilter as li, resetErrorFilter as di } from "../error"
import { getFileViewerFile as ti } from "../media/file/file.reducer"
import { resetFileViewer as ri } from "../media/file/file.action"
export function* uiLayoutSaga() {
  ;(yield l($),
    yield l(w),
    yield e(G, function* ({ payload: e }) {
      if (e === z.PROFILE) {
        const e = yield o(li)
        ;(e.key || e.value) && (yield i(di()))
      }
    }),
    yield e(E, function* () {
      ;(yield o(ti)) && (yield i(ri()))
    }),
    yield e([E, y, c], function* (e) {
      if ((yield o(Y)) && E.match(e)) return
      const [l, t, r] = yield d([o(f), o(s), o(p)])
      u(l)
        ? t === r
          ? yield i(v({ chat: !0, callParticipants: !1 }))
          : yield i(v({ rooms: !0, chat: !0, callParticipants: !1 }))
        : yield i(v({ rooms: !0, chat: !0 }))
    }),
    yield e(m, function* () {
      ;(yield i(C(!0)),
        yield r(a),
        yield i(v({ rooms: !1, chat: !1 })),
        yield r(oi),
        yield i(C(!1)))
    }),
    yield e(n, function* () {
      yield i(v({ chat: !1, rooms: !1 }))
    }),
    yield e(A, function* ({ payload: e }) {
      const l = yield o(M)
      e && l !== J.SYNC_DEVICE && (yield i(j(J.SYNC_DEVICE)))
    }),
    yield e(F, function* () {
      yield i(v({ profile: !1 }))
    }),
    yield e([I, N], function* () {
      const [e, l] = yield d([o(h), o(M)])
      ;(e === O.RUNNING && l !== J.ROOM && (yield i(j(J.ROOM))),
        e === O.IDENTITY_SETUP && l === J.ROOM && (yield i(j(J.IDENTITY_SETUP))))
    }),
    yield e(R, function* ({ payload: e }) {
      const { memberId: o } = e
      yield i(X({ memberId: o }))
    }),
    yield e(V, function* () {
      yield i(Z(null))
    }),
    yield e(k, function* () {
      yield i(W(null))
    }),
    yield t([K, B], function* () {
      const { PAIRING: e, JOINED: l, DM_REQUESTS: d } = q,
        t = yield o(H),
        r = yield o(U)
      if (t) yield i(g(e))
      else
        switch (r) {
          case d:
          case e:
            yield i(g(l))
        }
    }),
    yield t([ei], function* () {
      ;(yield o(ii)) && (yield i(g(q.DM_REQUESTS)), yield i(b()))
    }),
    yield e(T, function* () {
      const [e, l, t, r] = yield d([o(f), o(S), o(x), o(D)])
      u(e) && l && t && r && (yield i(v({ rooms: !0, chat: !0 })))
    }),
    yield e(v, function* () {
      const { chat: e } = yield o(L),
        l = yield o(P)
      e && l ? yield i(_(!1)) : e || l || (yield i(_(!0)))
    }),
    yield e(Q, function* (e) {
      const l = yield o(P),
        d = e.payload
      d || l ? d && l && (yield i(_(!1))) : yield i(_(!0))
    }),
    yield e(v, function* (e) {
      const { rooms: l, chat: d } = e.payload
      ;(yield o(D)) && !1 === l && !1 === d && (yield i(T()))
    }))
}