Commit c4df3af0 authored by yPhil's avatar yPhil
Browse files

PTL.feed.js backPorts

parent de6626a9
Pipeline #417386 passed with stage
in 48 seconds
...@@ -7,21 +7,19 @@ PTL.feed = { ...@@ -7,21 +7,19 @@ PTL.feed = {
const $feed = $('<li>') const $feed = $('<li>')
.attr('class', 'feed'); .attr('class', 'feed');
// const errVar = true;
// errVar = 'plop';
const $feedImg = $('<img>') const $feedImg = $('<img>')
.attr({ .attr({
src: '/static/images/rss.gif', src: '/static/images/rss.gif',
class: 'favicon', class: 'favicon',
width: '16px', width: '16px',
height: '16px' height: '16px'
}) })
.on("error", function() { .on("error", function() {
$(this).attr('src', '/static/images/rss.gif'); $(this).attr('src', '/static/images/rss.gif');
}); $(this).parent().parent().children('div.dataStore').data('iconhash', '');
PTL.tab.saveTabs();
});
const $newItemsBadge = $('<div>') const $newItemsBadge = $('<div>')
.attr('class', 'newItemsBadge hidden'); .attr('class', 'newItemsBadge hidden');
...@@ -412,8 +410,6 @@ PTL.feed = { ...@@ -412,8 +410,6 @@ PTL.feed = {
}, },
errorFeed:function(error, feedUrl) { errorFeed:function(error, feedUrl) {
console.log('pow: %s', feedUrl);
const type = (error.statusText) ? error.statusText : PTL.tr('Unknown error'); const type = (error.statusText) ? error.statusText : PTL.tr('Unknown error');
const errno = (error.responseJSON) ? error.responseJSON.errno : '0'; const errno = (error.responseJSON) ? error.responseJSON.errno : '0';
const message = (error.responseJSON) ? error.responseJSON.message : 'Empty'; const message = (error.responseJSON) ? error.responseJSON.message : 'Empty';
...@@ -553,27 +549,9 @@ PTL.feed = { ...@@ -553,27 +549,9 @@ PTL.feed = {
$badge.fadeOut('slow'); $badge.fadeOut('slow');
} }
if (feedIconHash) {
$favIcon.attr('src', '/favicons/' + feedIconHash + '.favicon');
} else {
await PTL.feed.fetchIcon(feedHost).then((iconhash) => {
if (iconhash) {
$favIcon.attr('src', '/favicons/' + iconhash + '.favicon');
$dataStore.data('iconhash', iconhash);
PTL.tab.saveTabs();
}
}).catch((_error) => {
console.log('Fav error: %s (%s)', feedIconHash, feedUrl);
$favIcon.addClass('icon-rss');
});
}
} catch (error) { } catch (error) {
console.log('Catched error: %s (%s)', JSON.stringify(error));
$feedBody.empty().append(PTL.feed.errorFeed(error, feedUrl)); $feedBody.empty().append(PTL.feed.errorFeed(error, feedUrl));
$feedBody.css('height', ''); $feedBody.css('height', '');
$refreshButton.removeClass('spin'); $refreshButton.removeClass('spin');
...@@ -590,59 +568,21 @@ PTL.feed = { ...@@ -590,59 +568,21 @@ PTL.feed = {
} }
if (progress) progress.increment();
// try {
// let feedInDb = await PTL.db.get(feedUrl);
// if (feedInDb) {
// $feedBody.html(feedInDb.content);
// } else {
// feedLastItem = 'none';
// }
// try {
// console.log('feedLastItem: %s (%s)', feedLastItem); if (feedIconHash) {
$favIcon.attr('src', '/favicons/' + feedIconHash + '.favicon');
// let fetchFeed = await PTL.feed.fetchFeed(feedUrl, feedLastItem); } else {
await PTL.feed.fetchIcon(feedHost).then((iconhash) => {
// console.log('fetchFeed: %s (%s)', JSON.stringify(fetchFeed)); if (iconhash) {
$favIcon.attr('src', '/favicons/' + iconhash + '.favicon');
// // $feedLink $dataStore.data('iconhash', iconhash);
// // .text(fetchFeed.feedTitle) PTL.tab.saveTabs();
// // .attr('title', fetchFeed.feedTitle + ' (' + feedUrl + ')'); }
}).catch((_error) => {
// if (fetchFeed.thereAreNewItems) { console.log('Fav error: %s (%s)', feedIconHash, feedUrl);
// $dataStore.data('lastitem', fetchFeed.lastItem); $favIcon.addClass('icon-rss');
// let lastItems = await PTL.feed.lastItems(fetchFeed.feedItems, $dataStore); });
// $feedBody.prepend(lastItems[0]); }
// PTL.db.put(feedUrl, $feedBody.html());
// $badge.text(lastItems[1]).fadeIn('slow');
// } else {
// // $dataStore.data('lastitem', 'none');
// $badge.fadeOut('slow');
// }
// $refreshButton
// .prop('title', PTL.tr('Refresh this feed (%1 - %2)', fetchFeed.feedTitle, timeStamp))
// .removeClass('spin');
// } catch (error) {
// console.log('Catched error: %s (%s)', JSON.stringify(error));
// $feedBody.empty().append(PTL.feed.errorFeed(error, feedUrl));
// $feedBody.css('height', '');
// $refreshButton.removeClass('spin');
// }
// } catch (error) {
// console.log('getFeed caught: %s (%s)', error);
// }
if (progress) progress.increment(); if (progress) progress.increment();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment