Skip to content

Commit

Permalink
fix: handle null ptr refrence if feed reader fails to load
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelroses committed Apr 15, 2024
1 parent cfd05bb commit 75facb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 0 additions & 1 deletion cmd/mainModal.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Quit
}
case key.Matches(msg, m.keys.Refresh):
// FIXME: if a feed fails to load and we use reload we get a memory address error
if m.context == "home" {
id, _ := strconv.Atoi(m.table.SelectedRow()[0])
feed := &m.feeds[id]
Expand Down
5 changes: 4 additions & 1 deletion lib/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ func GetContentForURL(url string) Feed {

func GetPosts(url string) []Post {
feed := setupReader(url)

posts := []Post{}

if feed == nil {
return posts
}

for _, item := range feed.Items {
post := createPost(item)
posts = append(posts, post)
Expand Down

0 comments on commit 75facb4

Please sign in to comment.