-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
26 changed files
with
407 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
|
||
import { useSelector } from 'react-redux'; | ||
|
||
import PodcastMatrix from './PodcastMatrix.jsx'; | ||
|
||
const LatestVisitedPodcasts = () => { | ||
const subscribedPodcasts = useSelector((state) => state.podcast.subscribedPodcasts); | ||
const [latestEpisodes,setLatestEpisodes] = useState(false); | ||
const [error,setError] = useState(false); | ||
|
||
const retrieveLatestEpisodes = async () => { | ||
// console.log(subscribedPodcasts); | ||
var feedPaths = []; | ||
for(var i=0;i<subscribedPodcasts.length;i++) { | ||
feedPaths.push(subscribedPodcasts[i].path); | ||
} | ||
|
||
try { | ||
var result = await fetch('https://api.podfriend.com/podcast/episodes/?feedPaths=' + feedPaths.join(',') + '&max=14'); | ||
var episodes = await result.json(); | ||
|
||
if (episodes.error) { | ||
setError(true); | ||
} | ||
else { | ||
setLatestEpisodes(episodes); | ||
} | ||
|
||
} | ||
catch (exception) { | ||
console.log('Error fetching latest episodes'); | ||
console.log(exception); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
retrieveLatestEpisodes(); | ||
},[]); | ||
|
||
if (error) { | ||
return null; | ||
} | ||
return ( | ||
<div className='section'> | ||
<div className='sectionInner'> | ||
<div className='sectionSubTitle'>Your</div> | ||
<div className='sectionTitle'>Latest episodes</div> | ||
</div> | ||
{ latestEpisodes !== false && | ||
<PodcastMatrix type='scrollList' episodes={latestEpisodes} showLoadMore={true} /> | ||
} | ||
</div> | ||
); | ||
} | ||
|
||
export default React.memo(LatestVisitedPodcasts); |
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
Oops, something went wrong.