Skip to content

Commit

Permalink
fix: don't delete when there's nothing to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
TypicalAM committed Aug 20, 2023
1 parent 6052a8b commit af738d3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions internal/ui/tab/feed/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Batch(m.spinner.Tick, m.fetcher(m.title, true))

case key.Matches(msg, m.keymap.SaveArticle):
index := absListIndex(&m.list, m.list.SelectedItem().FilterValue())
return m, backend.DownloadItem(m.title, index)
if item := m.list.SelectedItem(); item != nil {
return m, backend.DownloadItem(m.title, absListIndex(&m.list, item.FilterValue()))
}

case key.Matches(msg, m.keymap.DeleteFromSaved):
index := absListIndex(&m.list, m.list.SelectedItem().FilterValue())
return m, backend.DeleteItem(m, fmt.Sprintf("%d", index))
if item := m.list.SelectedItem(); item != nil {
return m, backend.DeleteItem(m, fmt.Sprintf("%d", absListIndex(&m.list, item.FilterValue())))
}

case key.Matches(msg, m.keymap.MarkAsUnread):
selectedItem := m.list.SelectedItem().(backend.ArticleItem)
Expand Down

0 comments on commit af738d3

Please sign in to comment.