OverviewFilesCommitsIssuesDocsReleasesPeers

keet-deobfuscated / @holepunchto / keet-store / store / identity / member / identity-member.reducer.js

26 lines · javascript ref:
import { createSlice as e, createAction as t } from "@reduxjs/toolkit"
import { resetModuleStateCmd as o } from "../../lib/rootAction"
import {
  IDENTITY_MEMBER_INITIAL_STATE as r,
  IDENTITY_MEMBER_STATE_KEY as m,
} from "./identity-member.constant"
export const blockMemberCmd = t("identity/block-member-cmd")
export const unblockMemberCmd = t("identity/unblock-member-cmd")
export const identityMemberSlice = e({
  name: m,
  initialState: r,
  reducers: {
    setBlockedMembers: (e, { payload: { blockedByMemberId: t } }) => {
      e.blockedByMemberId = t
    },
  },
  extraReducers: (e) => {
    e.addCase(o, () => r)
  },
})
export const getIdentityMembersState = (e) => e.identity[m]
export const getMemberBlockedByIdMap = (e) => getIdentityMembersState(e).blockedByMemberId
export const getMemberBlocked = (e, t) => !!getIdentityMembersState(e).blockedByMemberId[t]
export const { setBlockedMembers: setBlockedMembers } = identityMemberSlice.actions
export const isBlockedMembersDataEvt = (e) => setBlockedMembers.match(e)