From f322f71447cd7f980220dac206b1015e534d2c02 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 7 May 2018 18:16:30 +0200 Subject: [PATCH] - News widget max items is now configurable - Update the news list whenever the loop over the current list is done --- platypush/backend/http/static/js/widgets/rss-news.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platypush/backend/http/static/js/widgets/rss-news.js b/platypush/backend/http/static/js/widgets/rss-news.js index e65092d49..8cf46c56e 100644 --- a/platypush/backend/http/static/js/widgets/rss-news.js +++ b/platypush/backend/http/static/js/widgets/rss-news.js @@ -3,6 +3,7 @@ $(document).ready(function() { config = window.widgets['rss-news'], db = config.db, news = [], + default_limit = 10, cur_article_index = -1; var getNews = function() { @@ -15,7 +16,8 @@ $(document).ready(function() { query: "select s.title as source, e.title, e.summary, " + "strftime('%Y-%m-%dT%H:%M:%fZ', e.published) as published " + "from FeedEntry e join FeedSource s " + - "on e.source_id = s.id order by e.published desc limit 10" + "on e.source_id = s.id order by e.published desc limit " + + ('limit' in config ? config.limit : default_limit) } }, @@ -40,6 +42,7 @@ $(document).ready(function() { return; } + var updateNewsList = cur_article_index == news.length-1; var nextArticle = news[++cur_article_index % news.length]; var dt = new Date(nextArticle.published); var $article = $('
').addClass('article'); @@ -57,11 +60,14 @@ $(document).ready(function() { } $article.hide().appendTo($newsElement).fadeIn(); + + if (updateNewsList) { + getNews(); + } }; var initWidget = function() { getNews(); - setInterval(getNews, 600000); setInterval(refreshNews, 15000); };