A personal plugin adds hotkeys for "Show articles" and "Sort articles" menus plus enhanced un/collapse action

Announcing a personal plugin others might find useful.

Sorry, the name is a bit vain but when I searched for an available “root” hotkey, “R” was available and so far it has stuck. :slight_smile: Comments, suggestions, contributions welcome. README :

TTRSS Rodney’s Hotkeys Plugin

Add hotkeys to change “Show articles” and “Sort articles” settings. Add a hotkey to replace ‘x’ un/collapse to include parent category if current selected folder is a feed.

Prefs

Sometimes I like to read starred articles oldest to newest (especially articles in a series or videos that build on the next/previous one). I would like to have the “Show articles” and “Sort articles” menu options as hotkeys. Also I find myself hitting “x” a lot to collapse a category and it doesn’t work b/c the current folder is a feed. This plugin addresses all of these preferences w/o resorting to mouse clicks.

Hotkeys

  • x => Un/collapse current category (or parent category if current selection is a feed)

  • Show articles

    • R A => Adaptive
    • R L => All Articles
    • R S => Starred
    • R P => Published
    • R U => Unread
    • R W => With Note
  • Sort articles

    • R D => Default
    • R N => Newest first
    • R O => Oldest first
    • R T => Title

Thanks to Gilles Grandou’s plugin toggle_sort_titles for the pattern/starting point.

I just added a binding to the spacebar that “scrolls down a bit”; 1/8th of the screen instead of 1/2 the screen for page up/dn. I when reading I like to keep my eye scan near the top of the window. This help b/c it scrolls about 4 lines for me (depends on window height YMMV).

CHANGELOG: Since the latest updates to tt-rss the spacebar binding didn’t make sense; the up/down arrow keys scroll “a bit” now. So I deleted the binding rather than update the javascript to match the new code.

@rodneys_mission … I created an issue over at gitlab a few weeks ago regarding an intermittent ‘unhandled exception’ when using this plugin. If you have some time at some point, please take a look. Thanks.
.

Confirmed. This is from the big code refactors of late.

This stems from the line (used when collapsing the parent category):

init.js:56: dijit.byId(“feedTree”).collapseCat(Feeds.getCategory(Feeds.getActive()));

‘getCategory’ is returning false instead of the feed’s category id. I searched all js files for “_cat_of_feed” (b/c that is was getCategory should return) and I only get 1 hit:

../../js/Feeds.js:529: return tree._cat_of_feed(feed);

What that means is that getCategory is returning an undefined attribute that will never be set, that is broken behavior.

@fox, is this a bug? Deprecated function? Or is there another “cannon” way to get a feed’s category id?

This works:
dijit.byId(“feedTree”).collapseCat(dijit.byId(“feedTree”).getFeedCategory(Feeds.getActive()));

But that is a lot of indirection and accessing attributes directly instead of via class methods. Ideas?

this seems like an unused shortcut helper which got broken at some point (i’m too lazy to check git history) and i’ve never noticed because it’s not used anywhere.

it should be updated to invoke relevant method from the feedtree if its available and fail gracefully if it isn’t. i’ll make a note.

at the end of the day feedtree holds all this information, you can just deal with it directly, although you should be aware that it might not be available at all times (if its not been loaded yet etc)

Ok, thanks. The relevant code is invoked by a hotkey, so the tree should exist. I could add some prophylactic code to check … or let the user try again once loaded. :man_shrugging:

I updated the 1 return line to the “before times” and submitted a PR. getCategory isn’t used, but it should be correct (or deprecated).