Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Specific ignoreOlderThan value (override) per URL Feature, Issue #3360 #3429

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

AartiPhatke
Copy link

Hello,
I added the feature request in the newsfeed module for being able to set ignoreOlderThan for each newsfeed rather than have a global variable for it. To do this however, instead of adding an ignoreOlderThanOveride parameter, I changed ignoreOldItems and ignoreOlderThan to be arrays so they can hold values for each news feed. I also changed the logic for how these variables are accessed in generateFeed(). I also ran 'npm run test' and some of the unit tests for the calendar module were failing, I don't think this is related to my PR but I wanted to mention it.
Hope this helps!

@sdetweil
Copy link
Collaborator

sdetweil commented Apr 26, 2024

it would be easier to add the variables for each feed and then use a function that returned the feed value or the default if not specified

and use that function instead of the direct value access in the genersteFeed function

…de a function that returned values from the feed
@AartiPhatke
Copy link
Author

AartiPhatke commented Apr 26, 2024

Hello,
I made this fix!

@@ -5,7 +5,9 @@ Module.register("newsfeed", {
{
title: "New York Times",
url: "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml",
encoding: "UTF-8" //ISO-8859-1
encoding: "UTF-8", //ISO-8859-1
ignoreOldItems: false,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than having ignorOldItems and ignorOlderThan be global parameters, I added them inside the feed array and gave then default values of false and 1day.

@@ -176,19 +180,23 @@ Module.register("newsfeed", {
});
}
},

getFeedProperty(feed, property) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this function so you can access values inside the objects in the feed array.

for (let item of feedItems) {
item.sourceTitle = this.titleForFeed(feed);
if (!(this.config.ignoreOldItems && Date.now() - new Date(item.pubdate) > this.config.ignoreOlderThan)) {
let ignoreOldItems = getFeedProperty(feedItems, 'ignoreOldItems');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed how the the variables are accessed when trying to display the feed by using the getFeedProperty()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants