diff --git a/internal/display/input.go b/internal/display/input.go index 18cf34a..9c3078c 100644 --- a/internal/display/input.go +++ b/internal/display/input.go @@ -143,25 +143,26 @@ func (d *display) whileReading(input byte, quitC chan bool) { case 'r': if d.currentSection == URLS_LIST { - f, err := d.fetchFeed(string(d.raw[d.currentRow()])) + parsedFeed, err := d.fetchFeed(string(d.raw[d.currentRow()])) if err != nil { log.Default().Println(err) d.setTmpBottomMessage(2*time.Second, "cannot parse feed!") return } - f.CountUnread() + parsedFeed.CountUnread() // TODO rewrite single line with d.writeLineAt - d.rendered[d.currentRow()] = fromString(util.RenderFeedRow(f.UnreadCount, len(f.Items), f.Name)) + d.rendered[d.currentRow()] = fromString(util.RenderFeedRow(parsedFeed.UnreadCount, len(parsedFeed.Items), parsedFeed.Name)) } - case 'a': + case 'R': if d.currentSection == URLS_LIST { - d.enterEditingMode() + d.fetchAllFeeds() + d.renderFeedList() } - case 'R': + case 'a': if d.currentSection == URLS_LIST { - d.fetchAllFeeds() + d.enterEditingMode() } case 'o': diff --git a/internal/display/loading.go b/internal/display/loading.go index 7a1a2d8..c1868eb 100644 --- a/internal/display/loading.go +++ b/internal/display/loading.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "log" + "log/slog" "sort" "strings" "time" @@ -68,6 +69,7 @@ func (d *display) fetchFeed(url string) (*feed.Feed, error) { log.Default().Println(err.Error()) } }() + return parsedFeed, nil } @@ -112,16 +114,18 @@ func (d *display) fetchAllFeeds() { } if err := g.Wait(); err != nil { + slog.Error("reload failed", "err", err) d.setTmpBottomMessage(2*time.Second, "cannot reload all feeds!") - } else { - go func() { - if err := d.cache.Encode(); err != nil { - log.Default().Println(err.Error()) - } - }() - - log.Default().Println("reloaded all feeds in: ", time.Since(start)) + return } + + go func() { + if err := d.cache.Encode(); err != nil { + log.Default().Println(err.Error()) + } + }() + + log.Default().Println("reloaded all feeds in: ", time.Since(start)) } func (d *display) loadArticleList(url string) error { diff --git a/internal/feed/parser.go b/internal/feed/parser.go index 79092fd..d9bede2 100644 --- a/internal/feed/parser.go +++ b/internal/feed/parser.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "log" + "log/slog" "strings" "time" @@ -37,6 +38,7 @@ func (p *Parser) Parse(url string) (*Feed, error) { defer cancel() parsedFeed, err := p.ParseURLWithContext(url, ctx) if err != nil { + slog.Error("cannot parse feed", "url", url, "err", err) return nil, err } return NewFeedFrom(parsedFeed, url), nil