import { List } from 'immutable'; import auth from './auth'; import config from './config'; import integrations, * as fromIntegrations from './integrations'; import entries, * as fromEntries from './entries'; import cursors from './cursors'; import entryDraft from './entryDraft'; import collections from './collections'; import search from './search'; import medias from './medias'; import mediaLibrary from './mediaLibrary'; import globalUI from './globalUI'; import status from './status'; import scroll from './scroll'; import type { State, Collection } from '../types/redux'; const reducers = { auth, config, collections, search, integrations, entries, cursors, entryDraft, medias, mediaLibrary, globalUI, status, scroll, }; export default reducers; /* * Selectors */ export function selectEntry(state: State, collection: string, slug: string) { return fromEntries.selectEntry(state.entries, collection, slug); } export function selectEntries(state: State, collection: Collection) { return fromEntries.selectEntries(state.entries, collection); } export function selectPublishedSlugs(state: State, collection: string) { return fromEntries.selectPublishedSlugs(state.entries, collection); } export function selectSearchedEntries(state: State, availableCollections: string[]) { // only return search results for actually available collections return List(state.search.entryIds) .filter(entryId => availableCollections.indexOf(entryId!.collection) !== -1) .map(entryId => fromEntries.selectEntry(state.entries, entryId!.collection, entryId!.slug)); } export function selectIntegration(state: State, collection: string | null, hook: string) { return fromIntegrations.selectIntegration(state.integrations, collection, hook); }