diff --git a/NOTES.md b/NOTES.md index 9c5a0af..da2c060 100644 --- a/NOTES.md +++ b/NOTES.md @@ -3,13 +3,10 @@ ## Feeds (temp) - Feed page doesn't update automatically if you add a feed by bottom bar URL while already on the feed page - TODO: remove all logger lines - + ## Issues - URL for each tab should not be stored as a string - in the current code there's lots of reparsing the URL -## Regressions - - ## Upstream Bugs - Wrapping messes up on brackets - Filed [issue 23](https://gitlab.com/tslocum/cview/-/issues/23) diff --git a/display/feeds.go b/display/feeds.go index 3478a32..aacd1b7 100644 --- a/display/feeds.go +++ b/display/feeds.go @@ -158,10 +158,12 @@ func getFeedFromPage(p *structs.Page) (*gofeed.Feed, bool) { // addFeedDirect is only for adding feeds, not pages. // It's for when you already have a feed and know if it's tracked. -// Use mainly by handleURL because it already did a lot of the work. +// Used mainly by handleURL because it already did a lot of the work. +// It returns a bool indicating whether the user actually wanted to +// add the feed or not. // // Like addFeed, it should be called in a goroutine. -func addFeedDirect(u string, feed *gofeed.Feed, tracked bool) { +func addFeedDirect(u string, feed *gofeed.Feed, tracked bool) bool { logger.Log.Println("display.addFeedDirect called") if openFeedModal(true, tracked) { @@ -169,7 +171,9 @@ func addFeedDirect(u string, feed *gofeed.Feed, tracked bool) { if err != nil { Error("Feed Error", err.Error()) } + return true } + return false } // addFeed goes through the process of tracking the current page/feed. diff --git a/display/private.go b/display/private.go index 69b5200..3ebe5f8 100644 --- a/display/private.go +++ b/display/private.go @@ -593,7 +593,13 @@ func handleURL(t *tab, u string, numRedirects int) (string, bool) { mediatype, _, _ := mime.ParseMediaType(res.Meta) feed, ok := feeds.GetFeed(mediatype, filename, res.Body) if ok { - go addFeedDirect(u, feed, feeds.IsTracked(u)) + go func() { + added := addFeedDirect(u, feed, feeds.IsTracked(u)) + if !added { + // Otherwise offer download choices + go dlChoice("That file could not be displayed. What would you like to do?", u, res) + } + }() return ret("", false) }