diff --git a/src/components/organisms/passageNavigation/index.graphql b/src/components/organisms/passageNavigation/index.graphql index 1494d1f23..6a9081a7f 100644 --- a/src/components/organisms/passageNavigation/index.graphql +++ b/src/components/organisms/passageNavigation/index.graphql @@ -1,11 +1,19 @@ +fragment passageNavigationChapter on Recording { + id + title + canonicalPath(useFuturePath: true) + collection { + id + contentType + } +} + fragment passageNavigationBook on Sequence { id title recordings(first: 150) { nodes { - id - title - ...andMiniplayer + ...passageNavigationChapter } } } @@ -19,13 +27,3 @@ fragment passageNavigationVersion on Collection { } } } - -fragment passageNavigationChapter on Recording { - id - title - canonicalPath(useFuturePath: true) - collection { - id - contentType - } -} diff --git a/src/lib/getBibles.ts b/src/lib/getBibles.ts index 184ab7d54..e1e6243a3 100644 --- a/src/lib/getBibles.ts +++ b/src/lib/getBibles.ts @@ -1,9 +1,6 @@ -import { - CollectionContentType, - Language, - RecordingContentType, - SequenceContentType, -} from '~src/__generated__/graphql'; +import pMemoize from 'p-memoize'; + +import { CollectionContentType, Language } from '~src/__generated__/graphql'; import { BibleIndexProps } from '~src/containers/bible'; import { getAudiobibleIndexData } from '~src/containers/bible/__generated__'; import { BOOK_ID_MAP } from '~src/services/fcbh/constants'; @@ -49,23 +46,10 @@ async function transform( .bookId(bookId) .chapterNumber(bbChapter.number) .get(), - duration: bbChapter.duration, - recordingContentType: RecordingContentType.BibleChapter, - sequence: { - id: bbChapter.id, - title, - contentType: SequenceContentType.BibleBook, - }, - audioFiles: [], - videoFiles: [], - videoStreams: [], collection: { id: bible.id, - title: bible.title, contentType: CollectionContentType.BibleVersion, }, - speakers: [], - sponsor: null, }; }, ); @@ -121,14 +105,20 @@ function concatBibles( ); } -export default async function getBibles(languageId: Language): Promise<{ - fcbh: ApiBible[] | null; - api: ApiBible[] | null; - all: ApiBible[]; -}> { - const fcbh = await getFcbhBibles(languageId); - const api = await getApiBibles(languageId); - const all = concatBibles(fcbh, api); +const getBibles = pMemoize( + async ( + languageId: Language, + ): Promise<{ + fcbh: ApiBible[] | null; + api: ApiBible[] | null; + all: ApiBible[]; + }> => { + const fcbh = await getFcbhBibles(languageId); + const api = await getApiBibles(languageId); + const all = concatBibles(fcbh, api); - return { fcbh, api, all }; -} + return { fcbh, api, all }; + }, +); + +export default getBibles;