Skip to content

Commit

Permalink
fix: actually add the category if we succeed
Browse files Browse the repository at this point in the history
  • Loading branch information
TypicalAM committed Jul 4, 2023
1 parent dab7a88 commit cf17742
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/model/browser/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil

case popup.ChosenCategoryMsg:
m.message = fmt.Sprintf("Chosen category: %s", msg.Name)
m.popupShown = false
return m, nil
if err := m.config.Backend.Rss.AddCategory(msg.Name, ""); err != nil {
m.message = fmt.Sprintf("Error adding category: %s", err.Error())
} else {
m.message = fmt.Sprintf("Added category %s", msg.Name)
}

return m, m.config.Backend.FetchCategories()

case tab.NewTabMessage:
// Create the new tab
Expand Down
2 changes: 2 additions & 0 deletions internal/popup/popup.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (p Popup) Update(msg tea.Msg) (Popup, tea.Cmd) {
cmds = append(cmds, p.textInput.Focus())
case newCategoryField:
p.focused = allField
p.textInput.Blur()
}

case "up", "k":
Expand All @@ -108,6 +109,7 @@ func (p Popup) Update(msg tea.Msg) (Popup, tea.Cmd) {
p.focused = allField
case newCategoryField:
p.focused = downloadedField
p.textInput.Blur()
}

case "enter":
Expand Down

0 comments on commit cf17742

Please sign in to comment.