OverviewFilesCommitsIssuesDocsReleasesPeers

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

71 lines · javascript ref:
import {
  select as e,
  put as i,
  takeLatest as o,
  takeLeading as t,
  call as d,
} from "redux-saga/effects"
import { memberRemoveSuccess as l } from "../member"
import { UI_PANEL as n, ROOM_INFO_SECTION as r } from "./ui.constants"
import {
  setRoomInfoSectionsStack as y,
  closeUIPanel as c,
  toggleUIPanel as m,
  uiRoomInfoGoBackCmd as s,
  ROOM_INFO_SECTION_STACK_DEFAULT as a,
  getRoomInfoCurrentSectionData as f,
  ROOM_INFO_SECTION_ROOT as u,
  getRoomInfoSectionsStack as p,
  uiRoomInfoGoToCmd as E,
  getUIPanelRoomInfoOpen as M,
  resetUIPanels as I,
  uiRoomInfoGoToMemberCmd as O,
} from "./ui.reducer"
import { getAppCurrentRoomId as R, setAppCurrentRoomId as _ } from "../app/app.reducer"
import {
  canCurrentMemberManageRoles as b,
  roomFilesInitialFetchSaga as S,
  switchRoomSubmit as g,
} from "../room"
import { last as B } from "../lib/array"
const { ROOT: F, FILES: N, DM_REQUEST_MEMBER: h, MANAGE_MEMBER: v, MEMBER: x } = r
export function* uiRoomInfoSectionSaga() {
  ;(yield o(_, function* () {
    ;(yield e(M)) && (yield i(c(n.ROOM_INFO)))
  }),
    yield o(y, function* () {
      const { section: i } = yield e(f),
        o = yield e(R)
      i === N && (yield d(S, { roomId: o }))
    }),
    yield o(s, function* () {
      const o = yield e(p),
        t = o.length > 1 ? o.slice(0, -1) : a
      yield i(y(t))
    }),
    yield o(E, function* (o) {
      const { payload: t } = o,
        {
          section: d,
          sectionParams: { roomId: l },
        } = t,
        r = yield e(R)
      l && l !== r && (yield i(g({ roomId: l })))
      const c = yield e(M)
      if ((c || (yield i(I()), yield i(m({ key: n.ROOM_INFO, value: !0 }))), d === F))
        return void (yield i(y(a)))
      let s = yield e(p)
      c || (s = [u])
      const f = B(s)?.section
      let E = f === d ? s.slice(0, -1) : [...s]
      ;(E.push(t), c || d !== h || (E = [t]), yield i(y(E)))
    }),
    yield o(O, function* ({ payload: { memberId: o } }) {
      const t = (yield e(b)) ? v : x
      yield i(E({ section: t, sectionParams: { memberId: o } }))
    }),
    yield t(l, function* () {
      yield i(y(a))
    }))
}