mirror of
https://github.com/charmbracelet/gum
synced 2024-06-15 20:15:08 +02:00
refactor: remove default value tranport using timeout Message
This commit is contained in:
parent
02d0bf4dbc
commit
d00b8dcdd1
|
@ -18,10 +18,6 @@ import (
|
|||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
type defaultVal struct {
|
||||
Value bool
|
||||
}
|
||||
|
||||
type model struct {
|
||||
prompt string
|
||||
affirmative string
|
||||
|
@ -39,7 +35,7 @@ type model struct {
|
|||
}
|
||||
|
||||
func (m model) Init() tea.Cmd {
|
||||
return timeout.Init(m.timeout, defaultVal{Value: m.confirmation})
|
||||
return timeout.Init(m.timeout, m.defvalue)
|
||||
}
|
||||
|
||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
|
@ -75,12 +71,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||
|
||||
if msg.TimeoutValue <= 0 {
|
||||
m.quitting = true
|
||||
if v, ok := msg.Data.(defaultVal); ok {
|
||||
m.confirmation = v.Value
|
||||
} else {
|
||||
m.confirmation = false
|
||||
}
|
||||
|
||||
m.confirmation = m.defvalue
|
||||
return m, tea.Quit
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue