55 lines
1.5 KiB
TypeScript
Raw Normal View History

2016-06-10 00:16:01 -03:00
import auth from './auth';
2022-10-20 11:57:30 -04:00
import collections from './collections';
2016-06-10 00:16:01 -03:00
import config from './config';
import cursors from './cursors';
2022-10-20 11:57:30 -04:00
import entries, * as fromEntries from './entries';
2016-06-10 00:16:01 -03:00
import entryDraft from './entryDraft';
import globalUI from './globalUI';
2022-10-20 11:57:30 -04:00
import mediaLibrary from './mediaLibrary';
import medias from './medias';
2022-09-20 09:14:34 -04:00
import scroll from './scroll';
2022-10-20 11:57:30 -04:00
import search from './search';
import status from './status';
2022-10-20 11:57:30 -04:00
import type { Collection } from '../interface';
import type { RootState } from '../store';
2016-06-10 00:16:01 -03:00
const reducers = {
auth,
collections,
2022-11-04 17:41:12 -04:00
config,
cursors,
2022-11-04 17:41:12 -04:00
entries,
2016-06-10 00:16:01 -03:00
entryDraft,
globalUI,
2022-11-04 17:41:12 -04:00
mediaLibrary,
medias,
2022-09-20 09:14:34 -04:00
scroll,
2022-11-04 17:41:12 -04:00
search,
status,
2016-06-10 00:16:01 -03:00
};
export default reducers;
2016-09-06 13:04:17 -03:00
/*
* Selectors
*/
2022-10-20 11:57:30 -04:00
export function selectEntry(state: RootState, collection: string, slug: string) {
return fromEntries.selectEntry(state.entries, collection, slug);
}
2016-06-10 00:16:01 -03:00
2022-10-20 11:57:30 -04:00
export function selectEntries(state: RootState, collection: Collection) {
return fromEntries.selectEntries(state.entries, collection);
}
2016-06-10 00:16:01 -03:00
2022-10-20 11:57:30 -04:00
export function selectPublishedSlugs(state: RootState, collection: string) {
return fromEntries.selectPublishedSlugs(state.entries, collection);
}
2022-10-20 11:57:30 -04:00
export function selectSearchedEntries(state: RootState, availableCollections: string[]) {
// only return search results for actually available collections
2022-10-20 11:57:30 -04:00
return state.search.entryIds
.filter(entryId => availableCollections.indexOf(entryId!.collection) !== -1)
.map(entryId => fromEntries.selectEntry(state.entries, entryId!.collection, entryId!.slug));
}