Skip to content

Commit

Permalink
Merge pull request #31 from amcquade/update-fixes
Browse files Browse the repository at this point in the history
Filter duplicate previous feeds, get previous feed when it is clicked
  • Loading branch information
amcquade authored Oct 23, 2020
2 parents 82f8a91 + 707ec54 commit a506b04
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const App = ({ fetching }) => {

const getFeed = (event) => {
setFetching((prev) => !prev);
event.preventDefault();
if (event.preventDefault != null)
event.preventDefault();
const feed_url = event.target.elements.feed_url.value;
const Parser = require("rss-parser");
const parser = new Parser({
Expand All @@ -44,7 +45,7 @@ const App = ({ fetching }) => {
program_description: feed.description,
});
setFetching((prev) => !prev);
setPreviousFeeds([...previousFeeds, feed_url]);
setPreviousFeeds([...new Set([...previousFeeds, feed_url])]);
setPast(true);

return setError(false);
Expand Down
6 changes: 4 additions & 2 deletions src/components/SearchHistory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export default function SearchHistory(props) {
setAnchorEl(event.currentTarget);
};

const handleClose = () => {
const handleClose = (event) => {
if (event.currentTarget.innerText != '')
props.getFeed({target: {elements: {feed_url: {value: event.currentTarget.innerText}}}});
setAnchorEl(null);
};

const renderItem = (item, i) => {
return (
<MenuItem index={Math.random() * i} onClick={handleClose}>
<MenuItem key={i} index={i} onClick={handleClose}>
{item}
</MenuItem>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const UserForm = ({ getFeed, previous_feeds, past }) => {
>
Submit
</Button>
{past ? <SearchHistory history={previous_feeds} /> : <div></div>}
{past ? <SearchHistory getFeed={getFeed} history={previous_feeds} /> : <div></div>}
</form>
</div>
);
Expand Down

0 comments on commit a506b04

Please sign in to comment.