Skip to content

Commit

Permalink
Merge branch 'develop' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
Ponchimeow committed Oct 14, 2024
2 parents c7fbca9 + 2d30e34 commit 6d36bfe
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/hasura.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154944,6 +154944,7 @@ export type GetProgramContentEbookHighlight = { __typename?: 'query_root', progr

export type GET_PODCAST_PROGRAM_COLLECTIONVariables = Exact<{
creatorId?: InputMaybe<Scalars['String']>;
appId?: InputMaybe<Scalars['String']>;
}>;


Expand Down
12 changes: 9 additions & 3 deletions src/hooks/podcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@ import { StatusType } from '../types/general'
import { PlaylistProps, PodcastProgramContent, PodcastProgramContentProps } from '../types/podcast'

export const usePodcastProgramCollection = (creatorId?: string) => {
const { id: appId } = useApp()
const { loading, error, data, refetch } = useQuery<
hasura.GET_PODCAST_PROGRAM_COLLECTION,
hasura.GET_PODCAST_PROGRAM_COLLECTIONVariables
>(
gql`
query GET_PODCAST_PROGRAM_COLLECTION($creatorId: String) {
query GET_PODCAST_PROGRAM_COLLECTION($creatorId: String, $appId: String) {
podcast_program(
order_by: { published_at: desc }
where: {
podcast_program_roles: { member_id: { _eq: $creatorId }, name: { _eq: "instructor" } }
podcast_program_roles: {
member_id: { _eq: $creatorId }
name: { _eq: "instructor" }
member: { app_id: { _eq: $appId } }
}
published_at: { _is_null: false }
}
) {
Expand Down Expand Up @@ -56,7 +61,8 @@ export const usePodcastProgramCollection = (creatorId?: string) => {
`,
{
variables: {
creatorId: creatorId,
creatorId,
appId,
},
},
)
Expand Down
5 changes: 4 additions & 1 deletion src/pages/ActivityCollectionPage/ActivityCollectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ const ActivityCollectionPage = () => {

const filteredActivities = activities
.filter(activity => classification === null || activity.categories.some(category => category.id === classification))
.filter(activity => !activity.supportLocales || activity.supportLocales.find(locale => locale === currentLocale))
.filter(
activity =>
activity?.supportLocales === null || activity?.supportLocales?.some(locale => locale === currentLocale),
)

return (
<DefaultLayout white>
Expand Down
23 changes: 12 additions & 11 deletions src/pages/PodcastProgramCollectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ const PodcastProgramCollectionPage: React.VFC = () => {
uniqBy(category => category?.id, flatten(podcastPrograms.map(podcastProgram => podcastProgram.categories))),
)

const filteredPodcastPrograms = podcastPrograms
.filter(
podcastProgram =>
!selectedCategoryId || podcastProgram.categories?.some(category => category.id === selectedCategoryId),
)
.filter(
podcastProgram =>
podcastProgram?.supportLocales === null ||
podcastProgram?.supportLocales?.some(locale => locale === currentLocale),
)

useEffect(() => {
if (podcastPrograms) {
podcastPrograms.forEach((podcastProgram, index) => {
Expand Down Expand Up @@ -110,17 +121,7 @@ const PodcastProgramCollectionPage: React.VFC = () => {
<div className="row">
<div className="col-12 col-lg-8 mb-5">
<PodcastProgramTimeline
podcastPrograms={podcastPrograms
.filter(
podcastProgram =>
!selectedCategoryId ||
podcastProgram.categories?.some(category => category.id === selectedCategoryId),
)
.filter(
podcastProgram =>
!podcastProgram.supportLocales ||
podcastProgram.supportLocales.find(locale => locale === currentLocale),
)}
podcastPrograms={filteredPodcastPrograms}
renderItem={({ podcastProgram, isEnrolled, isSubscribed }) => (
<div id={podcastProgram.id}>
<CheckoutPodcastPlanModal
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProgramCollectionPage/ProgramCollectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ProgramCollectionPage: React.VFC = () => {
const filteredPrograms = programs.filter(
program =>
(!selectedCategoryId || program.categories?.some(category => category.id === selectedCategoryId)) &&
(!program.supportLocales || program.supportLocales.find(locale => locale === currentLocale)),
(program?.supportLocales?.some(locale => locale === currentLocale) || program.supportLocales === null),
)

useEffect(() => {
Expand Down

0 comments on commit 6d36bfe

Please sign in to comment.