-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from SamTV12345/develop
Develop
- Loading branch information
Showing
17 changed files
with
231 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import {PlayIcon} from "./PlayIcon"; | ||
import axios, {AxiosResponse} from "axios"; | ||
import {apiURL, prepareOnlinePodcastEpisode, preparePodcastEpisode} from "../utils/Utilities"; | ||
import {PodcastWatchedModel} from "../models/PodcastWatchedModel"; | ||
import {store} from "../store/store"; | ||
import {setCurrentPodcast, setCurrentPodcastEpisode, setPlaying} from "../store/AudioPlayerSlice"; | ||
import {FC} from "react"; | ||
import {selectPodcastImage} from "../pages/Homepage"; | ||
import {TimeLineModel} from "../models/TimeLineModel"; | ||
import {useAppDispatch} from "../store/hooks"; | ||
|
||
|
||
type PodcastEpisodeTimeLineProps = { | ||
podcastEpisode: TimeLineModel | ||
} | ||
|
||
export const PodcastEpisodeTimeLine:FC<PodcastEpisodeTimeLineProps> = ({podcastEpisode}) => { | ||
const dispatch = useAppDispatch() | ||
|
||
return <div key={podcastEpisode.podcast_episode.episode_id+"dv"} | ||
className="max-w-sm rounded-lg shadow bg-gray-800 border-gray-700"> | ||
<div className="relative" key={podcastEpisode.podcast_episode.episode_id}> | ||
<img src={selectPodcastImage(podcastEpisode.podcast_episode)} alt="" className=""/> | ||
<div className="absolute left-0 top-0 w-full h-full hover:bg-gray-500 opacity-80 z-10 grid place-items-center play-button-background"> | ||
<PlayIcon key={podcastEpisode.podcast_episode.episode_id+"icon"} podcast={podcastEpisode.podcast_episode} className="w-20 h-20 opacity-0" onClick={()=>{ | ||
axios.get(apiURL+"/podcast/episode/"+podcastEpisode.podcast_episode.episode_id) | ||
.then((response: AxiosResponse<PodcastWatchedModel>)=>{ | ||
if (podcastEpisode.podcast_episode.local_image_url.trim().length>1){ | ||
store.dispatch(setCurrentPodcastEpisode(preparePodcastEpisode(podcastEpisode.podcast_episode, response.data))) | ||
} | ||
else{ | ||
store.dispatch(setCurrentPodcastEpisode(prepareOnlinePodcastEpisode(podcastEpisode.podcast_episode, response.data))) | ||
} | ||
dispatch(setCurrentPodcast(podcastEpisode.podcast)) | ||
dispatch(setPlaying(true)) | ||
}) | ||
}}/> | ||
</div> | ||
</div> | ||
<div className="p-5"> | ||
<h5 className="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white break-words">{podcastEpisode.podcast_episode.name}</h5> | ||
</div> | ||
</div> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {Podcast, PodcastEpisode} from "../store/CommonSlice"; | ||
|
||
export type TimeLineModel = { | ||
podcast: Podcast, | ||
podcast_episode: PodcastEpisode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import {useTranslation} from "react-i18next"; | ||
import {useAppDispatch, useAppSelector} from "../store/hooks"; | ||
import {useEffect, useMemo} from "react"; | ||
import axios, {AxiosResponse} from "axios"; | ||
import {apiURL, formatTime} from "../utils/Utilities"; | ||
import {PodcastEpisode, setTimeLineEpisodes} from "../store/CommonSlice"; | ||
import {PodcastEpisodeTimeLine} from "../components/PodcastEpisodeTimeLine"; | ||
import {TimeLineModel} from "../models/TimeLineModel"; | ||
|
||
const convertToTimeLineEpisodes = (podcastEpisodes: TimeLineModel[]) => { | ||
return podcastEpisodes.reduce((groups, game) => { | ||
const date = game.podcast_episode.date_of_recording.split('T')[0]; | ||
// @ts-ignore | ||
if (!groups[date]) { | ||
// @ts-ignore | ||
groups[date] = []; | ||
} | ||
// @ts-ignore | ||
groups[date].push(game); | ||
return groups; | ||
}, {}); | ||
} | ||
|
||
export const Timeline = ()=>{ | ||
const {t} = useTranslation() | ||
const dispatch = useAppDispatch() | ||
const timeLineEpisodes = useAppSelector(state=>state.common.timeLineEpisodes) | ||
const mappedEpisodes = useMemo(()=>convertToTimeLineEpisodes(timeLineEpisodes),[timeLineEpisodes]) | ||
|
||
useEffect(()=>{ | ||
axios.get(apiURL+"/podcasts/timeline") | ||
.then((c:AxiosResponse<TimeLineModel[]>)=>{ | ||
dispatch(setTimeLineEpisodes(c.data)) | ||
}) | ||
}, | ||
[]) | ||
|
||
console.log(convertToTimeLineEpisodes(timeLineEpisodes)) | ||
|
||
return <div className="p-3"> | ||
<h1 className="font-bold text-3xl">{t('timeline')}</h1> | ||
{ | ||
Object.keys(mappedEpisodes).map((e)=> { | ||
// @ts-ignore | ||
let episodesOnDate = mappedEpisodes[e] as TimeLineModel[] | ||
return <div key={e}><h2 className="text-xl">{formatTime(e)}</h2><div className="flex gap-4">{episodesOnDate.map((v)=><PodcastEpisodeTimeLine podcastEpisode={v} key={v.podcast_episode.episode_id+"Parent"}/>)}</div></div> | ||
} | ||
) | ||
|
||
} | ||
</div> | ||
} |
Oops, something went wrong.