2021-04-06 19:28:15 +03:00
|
|
|
import { List } from 'immutable';
|
2021-05-31 16:46:41 +02:00
|
|
|
|
2016-06-10 00:16:01 -03:00
|
|
|
import auth from './auth';
|
|
|
|
import config from './config';
|
2016-10-10 15:34:21 -03:00
|
|
|
import integrations, * as fromIntegrations from './integrations';
|
2016-10-18 12:32:39 -02:00
|
|
|
import entries, * as fromEntries from './entries';
|
2018-06-11 19:03:43 -07:00
|
|
|
import cursors from './cursors';
|
2016-06-10 00:16:01 -03:00
|
|
|
import entryDraft from './entryDraft';
|
|
|
|
import collections from './collections';
|
2016-12-07 15:44:07 -02:00
|
|
|
import search from './search';
|
2019-12-18 18:16:02 +02:00
|
|
|
import medias from './medias';
|
2017-08-14 09:00:47 -04:00
|
|
|
import mediaLibrary from './mediaLibrary';
|
2016-11-11 17:54:58 -02:00
|
|
|
import globalUI from './globalUI';
|
2020-06-03 12:44:03 +03:00
|
|
|
import status from './status';
|
2022-09-20 09:14:34 -04:00
|
|
|
import scroll from './scroll';
|
2021-05-31 16:46:41 +02:00
|
|
|
|
2021-05-31 14:23:16 +02:00
|
|
|
import type { State, Collection } from '../types/redux';
|
2016-06-10 00:16:01 -03:00
|
|
|
|
|
|
|
const reducers = {
|
|
|
|
auth,
|
|
|
|
config,
|
|
|
|
collections,
|
2016-12-07 15:44:07 -02:00
|
|
|
search,
|
2016-10-10 15:34:21 -03:00
|
|
|
integrations,
|
2016-06-10 00:16:01 -03:00
|
|
|
entries,
|
2018-06-11 19:03:43 -07:00
|
|
|
cursors,
|
2016-06-10 00:16:01 -03:00
|
|
|
entryDraft,
|
2016-10-18 12:32:39 -02:00
|
|
|
medias,
|
2019-12-18 18:16:02 +02:00
|
|
|
mediaLibrary,
|
2016-11-11 17:54:58 -02:00
|
|
|
globalUI,
|
2020-06-03 12:44:03 +03:00
|
|
|
status,
|
2022-09-20 09:14:34 -04:00
|
|
|
scroll,
|
2016-06-10 00:16:01 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
export default reducers;
|
|
|
|
|
2016-09-06 13:04:17 -03:00
|
|
|
/*
|
|
|
|
* Selectors
|
|
|
|
*/
|
2021-02-08 20:01:21 +02:00
|
|
|
export function selectEntry(state: State, collection: string, slug: string) {
|
|
|
|
return fromEntries.selectEntry(state.entries, collection, slug);
|
|
|
|
}
|
2016-06-10 00:16:01 -03:00
|
|
|
|
2021-02-08 20:01:21 +02:00
|
|
|
export function selectEntries(state: State, collection: Collection) {
|
|
|
|
return fromEntries.selectEntries(state.entries, collection);
|
|
|
|
}
|
2016-06-10 00:16:01 -03:00
|
|
|
|
2021-02-08 20:01:21 +02:00
|
|
|
export function selectPublishedSlugs(state: State, collection: string) {
|
|
|
|
return fromEntries.selectPublishedSlugs(state.entries, collection);
|
|
|
|
}
|
2019-04-10 21:38:53 +01:00
|
|
|
|
2021-02-08 20:01:21 +02:00
|
|
|
export function selectSearchedEntries(state: State, availableCollections: string[]) {
|
2020-05-18 09:52:06 +02:00
|
|
|
// only return search results for actually available collections
|
2021-04-06 19:28:15 +03:00
|
|
|
return List(state.search.entryIds)
|
|
|
|
.filter(entryId => availableCollections.indexOf(entryId!.collection) !== -1)
|
|
|
|
.map(entryId => fromEntries.selectEntry(state.entries, entryId!.collection, entryId!.slug));
|
2021-02-08 20:01:21 +02:00
|
|
|
}
|
2016-10-10 15:34:21 -03:00
|
|
|
|
2021-02-08 20:01:21 +02:00
|
|
|
export function selectIntegration(state: State, collection: string | null, hook: string) {
|
|
|
|
return fromIntegrations.selectIntegration(state.integrations, collection, hook);
|
|
|
|
}
|