FreshRSS / Extensions

A repository containing all the official FreshRSS extensions
GNU Affero General Public License v3.0
351 stars 54 forks source link

xExtension-ReadingTime displays reading time multiple times #116

Closed Poorchop closed 2 years ago

Poorchop commented 3 years ago

I installed this extension by downloading the extension archive, extracting it, and moving the xExtension-ReadingTime folder to ./extensions as instructed, and then I enabled it via the extensions configuration menu. I tried disabling and then re-enabling it, disabling the only other extension that I installed alongside it (xExtension-TitleWrap), and I tried using different themes but the problem persists no matter what.

Additional reading times will continue getting tacked on pretty much every time I expand and them collapse stories as I read my feeds get appended as I scroll down to load more articles.

screenshot

Edited for initially incorrectly reporting observed behavior

Alkarex commented 3 years ago

Something for @lapineige maybe?

lapineige commented 3 years ago

Additional reading times will continue getting tacked on pretty much every time I expand and them collapse stories as I read my feeds.

You mean it happens every time you open+close an article ? It is only on the first list of articles loaded, or also on the next ones ? Any case where it does not happen ?

SuperSandro2000 commented 3 years ago

This happens for me everytime I load more articles and the reading time is applied to all articles instead only the new ones.

Poorchop commented 3 years ago

When I first load FreshRSS, the reading time is applied twice so that I'll see something like <1m| <1m| Feed Title. I was incorrect in my initial report when I said that additional times get added when I expand/collapse stories. The behavior is as Sandro describes: reading time will be appended to all articles when new articles are loaded while scrolling down.

The only case in which the reading time doesn't get applied twice is when new articles are first loaded, excluding the first time that I open FreshRSS. When I first scroll down to load new articles, those articles will have the reading time displayed just once, but the time will be duplicated as I continue scrolling down to load more articles.

lapineige commented 3 years ago

I was incorrect in my initial report when I said that additional times get added when I expand/collapse stories.

That's good news, I thought there were a new big bug coming out of nowhere :sweat_smile:

Ok, then it's a know bug, I have it too. I think I know what's the underlying issue.

Sadly I haven't found time to fix it. It's probably something simple, perparps I should check if the text is already included in the title. But I have no time to implement and check it, sorry… (If someone is willing to try that, it would be much appreciated)

BrodyStone21 commented 2 years ago

Could anyone look at this? I think this is a useful extension but I can't use it if I'm seeing three different times next to each other.

Frenzie commented 2 years ago

@lapineige I'd probably add a data attribute, something like data-reading-time. It'd be quicker to check its existence and/or value than to recalculate.

lapineige commented 2 years ago

@Frenzie thanks for the suggestion, but I have no idea about how to do that (JS noob here) 😅 I need to take the time to learn all that, which sadly I haven't found yet…

Frenzie commented 2 years ago

Something along these lines is what I mean (NB mainly talking about setAttribute/getAttribute; I only briefly skimmed the code):

let item = document.querySelector('lalala');

if (item.getAttribute('data-reading-time') !== null) {
  // set the data attribute
  item.setAttribute('data-reading-time', reading_time.reading_time);
  // update the text
  item.textContent = item.textContent + reading_time.reading_time;