ckampfe/russ

[Bug] On a fresh install with no feeds copy/open link panics

NickLarsenNZ opened this issue · 4 comments

russ/src/app.rs

Lines 546 to 547 in abb911c

let feed = self.current_feed.clone().unwrap();
feed.link.clone().unwrap_or_else(|| feed.feed_link.unwrap())

image

I could update it to look like the piece a few lines down, like:

                if let Some(feed) = self.current_feed.clone() {
                    feed.link.clone().unwrap_or_else(|| feed.feed_link.unwrap())
                } else {
                    "".to_string()
                }

But I think it might be best to instead change the signature to

fn get_current_link(&self) -> Option<String> {
// ...

Then update the pieces of code that call it, do do nothing if it is a None variant.

Or perhaps add a variant to Selected to represent when nothing is selected, which is the case on a fresh install.

russ/src/modes.rs

Lines 2 to 6 in ed7757e

pub enum Selected {
Feeds,
Entries,
Entry(crate::rss::EntryMeta),
}

Hey @NickLarsenNZ I'm just commenting to say thank for your opening these issues and the PR! It'll likely be a few days before I can review them, but thanks for your contribution!

Thanks for the detailed writeup and suggested fixes @NickLarsenNZ. I was able to reproduce. Fixed in 81d16b0