OverviewFilesCommitsIssuesDocsReleasesPeers

keet-deobfuscated / @holepunchto / keet-store / store / reported-messages / reported-messages.selectors.js

22 lines · javascript ref:
import { createSelector as e } from "@reduxjs/toolkit"
import { REPORTED_MESSAGES_STATE_KEY as t } from "./reported-messages.constant"
import { EMPTY_ARRAY as s } from "../chat"
export const getReportedMessagesState = (e) => e[t]
export const getReportedMessagesOrder = (e) => getReportedMessagesState(e).sortedItems
export const getReportedMessagesIds = e(getReportedMessagesOrder, (e) => e.map((e) => e.id))
export const getReportedMessagesById = (e) => getReportedMessagesState(e).byId
export const getReportedMessagesMinClock = (e) => getReportedMessagesState(e).minClock
export const getReportedMessagesLoadingStatus = (e) => getReportedMessagesState(e).loadingStatus
export const getReportedMessagesInView = (e) => getReportedMessagesState(e).inView
export const getReportedMessagesgetAnchorOrderItem = e(
  [getReportedMessagesOrder, getReportedMessagesInView],
  (e, t) => e[t.top] || null,
)
export const getReportedMessagesAnchorClock = (e) =>
  getReportedMessagesgetAnchorOrderItem(e)?.clock || null
export const getReportedMessageItem = (e) => (t) => getReportedMessagesById(t)[e]
export const getSelectedReportedMessage = (e) => getReportedMessagesState(e).selectedItem
export const getReportedFileEntriesById = (e) => getReportedMessagesState(e).fileById
export const makeGetReportedFileEntriesByIds = (t) =>
  e(getReportedFileEntriesById, (e) => (t?.length ? t.map((t) => e[t]).filter(Boolean) : s))