automatically select the next unrated review

This commit is contained in:
Erik Winter 2024-01-13 19:02:28 +01:00
parent ca30027b0c
commit 3a3e3e73a2
2 changed files with 8 additions and 5 deletions

View File

@ -9,3 +9,5 @@ type Review struct {
Quality int Quality int
Mentions []string Mentions []string
} }
type ReviewStored string

View File

@ -67,7 +67,6 @@ func (m *tabReview) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "esc": case "esc":
m.mode = "view" m.mode = "view"
case "enter": case "enter":
m.mode = "view"
cmds = append(cmds, m.StoreReview()) cmds = append(cmds, m.StoreReview())
default: default:
cmds = append(cmds, m.updateFormInputs(msg)) cmds = append(cmds, m.updateFormInputs(msg))
@ -96,7 +95,10 @@ func (m *tabReview) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.logger.Log(fmt.Sprintf("got review %s", msg.ID)) m.logger.Log(fmt.Sprintf("got review %s", msg.ID))
m.selectedReview = msg m.selectedReview = msg
m.UpdateForm() m.UpdateForm()
case ReviewStored:
m.logger.Log(fmt.Sprintf("stored review %s", msg))
cmds = append(cmds, m.inputQuality.Focus())
cmds = append(cmds, FetchNextUnratedReview(m.emdb))
} }
return m, tea.Batch(cmds...) return m, tea.Batch(cmds...)
@ -193,12 +195,11 @@ func (m *tabReview) StoreReview() tea.Cmd {
m.selectedReview.Quality = quality m.selectedReview.Quality = quality
m.selectedReview.Mentions = strings.Split(mentions, ",") m.selectedReview.Mentions = strings.Split(mentions, ",")
review, err := m.emdb.UpdateReview(m.selectedReview) if err := m.emdb.UpdateReview(m.selectedReview); err != nil {
if err != nil {
return err return err
} }
return review return ReviewStored(m.selectedReview.ID)
} }
} }