Fine tuning + subtle behavioral adjustments to spinners + status messages

This commit is contained in:
Christian Rocha 2020-12-11 19:54:19 -05:00
parent 64da53ede6
commit 8d7b614688
3 changed files with 35 additions and 21 deletions

2
go.mod
View file

@ -4,7 +4,7 @@ go 1.13
require ( require (
github.com/alecthomas/chroma v0.8.0 // indirect github.com/alecthomas/chroma v0.8.0 // indirect
github.com/charmbracelet/bubbles v0.7.5 github.com/charmbracelet/bubbles v0.7.6-0.20201212003737-11f56f9b6b3f
github.com/charmbracelet/bubbletea v0.12.2 github.com/charmbracelet/bubbletea v0.12.2
github.com/charmbracelet/charm v0.8.2 github.com/charmbracelet/charm v0.8.2
github.com/charmbracelet/glamour v0.2.1-0.20200829234023-6c0e29c4dae5 github.com/charmbracelet/glamour v0.2.1-0.20200829234023-6c0e29c4dae5

6
go.sum
View file

@ -43,8 +43,8 @@ github.com/calmh/randomart v1.1.0 h1:evl+iwc10LXtHdMZhzLxmsCQVmWnkXs44SbC6Uk0Il8
github.com/calmh/randomart v1.1.0/go.mod h1:DQUbPVyP+7PAs21w/AnfMKG5NioxS3TbZ2F9MSK/jFM= github.com/calmh/randomart v1.1.0/go.mod h1:DQUbPVyP+7PAs21w/AnfMKG5NioxS3TbZ2F9MSK/jFM=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/charmbracelet/bubbles v0.6.0/go.mod h1:MxySU+YRGbAhZQJavZlW2os+fIeOW69MI3iXqA+2/WA= github.com/charmbracelet/bubbles v0.6.0/go.mod h1:MxySU+YRGbAhZQJavZlW2os+fIeOW69MI3iXqA+2/WA=
github.com/charmbracelet/bubbles v0.7.5 h1:N6TiahuRt2iGNE5gYxKBQ5/C6Lc8xxSp5LY9QJ09mS4= github.com/charmbracelet/bubbles v0.7.6-0.20201212003737-11f56f9b6b3f h1:6g/MQxdygWh8Ga0c5uR1Z8uz5wa3uaQjW0Hive/XBWw=
github.com/charmbracelet/bubbles v0.7.5/go.mod h1:IRTORFvhEI6OUH7WhN2Ks8Z8miNGimk1BE6cmHijOkM= github.com/charmbracelet/bubbles v0.7.6-0.20201212003737-11f56f9b6b3f/go.mod h1:0D4XRYK0tjo8JMvflz1obpVcOikNZSG46SFauoZj22s=
github.com/charmbracelet/bubbletea v0.10.3/go.mod h1:fB1bVmlaXBYYv4G0jtuGSP/m8V2sMM97pq7QqQnubWI= github.com/charmbracelet/bubbletea v0.10.3/go.mod h1:fB1bVmlaXBYYv4G0jtuGSP/m8V2sMM97pq7QqQnubWI=
github.com/charmbracelet/bubbletea v0.10.5/go.mod h1:Nay5oWkkSZvc6E/be+W3nDFXAsVytNUNKV9jbXcuae0= github.com/charmbracelet/bubbletea v0.10.5/go.mod h1:Nay5oWkkSZvc6E/be+W3nDFXAsVytNUNKV9jbXcuae0=
github.com/charmbracelet/bubbletea v0.12.2 h1:y9Yo2Pv8tcm3mAJsWONGsmHhzrbNxJVxpVtemikxE9A= github.com/charmbracelet/bubbletea v0.12.2 h1:y9Yo2Pv8tcm3mAJsWONGsmHhzrbNxJVxpVtemikxE9A=
@ -241,8 +241,6 @@ github.com/sabhiram/go-gitignore v0.0.0-20180611051255-d3107576ba94 h1:G04eS0JkA
github.com/sabhiram/go-gitignore v0.0.0-20180611051255-d3107576ba94/go.mod h1:b18R55ulyQ/h3RaWyloPyER7fWQVZvimKKhnI5OfrJQ= github.com/sabhiram/go-gitignore v0.0.0-20180611051255-d3107576ba94/go.mod h1:b18R55ulyQ/h3RaWyloPyER7fWQVZvimKKhnI5OfrJQ=
github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI= github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/segmentio/ksuid v1.0.3 h1:FoResxvleQwYiPAVKe1tMUlEirodZqlqglIuFsdDntY= github.com/segmentio/ksuid v1.0.3 h1:FoResxvleQwYiPAVKe1tMUlEirodZqlqglIuFsdDntY=
github.com/segmentio/ksuid v1.0.3/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE= github.com/segmentio/ksuid v1.0.3/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=

View file

@ -26,6 +26,7 @@ const (
stashViewTopPadding = 5 // logo, status bar, gaps stashViewTopPadding = 5 // logo, status bar, gaps
stashViewBottomPadding = 3 // pagination and gaps, but not help stashViewBottomPadding = 3 // pagination and gaps, but not help
stashViewHorizontalPadding = 6 stashViewHorizontalPadding = 6
stashedStatusMessage = "Stashed!"
) )
var ( var (
@ -111,19 +112,20 @@ const (
) )
type stashModel struct { type stashModel struct {
common *commonModel common *commonModel
err error err error
spinner spinner.Model spinner spinner.Model
noteInput textinput.Model noteInput textinput.Model
filterInput textinput.Model filterInput textinput.Model
stashFullyLoaded bool // have we loaded all available stashed documents from the server? stashFullyLoaded bool // have we loaded all available stashed documents from the server?
viewState stashViewState viewState stashViewState
filterState filterState filterState filterState
selectionState selectionState selectionState selectionState
showFullHelp bool showFullHelp bool
showStatusMessage bool showStatusMessage bool
statusMessage string statusMessage string
statusMessageTimer *time.Timer statusMessageTimer *time.Timer
stashStatusMessageQueued bool
// Available document sections we can cycle through. We use a slice, rather // Available document sections we can cycle through. We use a slice, rather
// than a map, because order is important. // than a map, because order is important.
@ -419,7 +421,7 @@ func newStashModel(common *commonModel) stashModel {
sp.Spinner = spinner.Line sp.Spinner = spinner.Line
sp.ForegroundColor = lib.SpinnerColor.String() sp.ForegroundColor = lib.SpinnerColor.String()
sp.HideFor = time.Millisecond * 50 sp.HideFor = time.Millisecond * 50
sp.MinimumLifetime = time.Millisecond * 180 sp.MinimumLifetime = time.Millisecond * 250
sp.Start() sp.Start()
ni := textinput.NewModel() ni := textinput.NewModel()
@ -558,6 +560,13 @@ func (m stashModel) update(msg tea.Msg) (stashModel, tea.Cmd) {
newSpinnerModel, cmd := m.spinner.Update(msg) newSpinnerModel, cmd := m.spinner.Update(msg)
m.spinner = newSpinnerModel m.spinner = newSpinnerModel
cmds = append(cmds, cmd) cmds = append(cmds, cmd)
} else if !stashing && !spinnerVisible && m.stashStatusMessageQueued {
m.stashStatusMessageQueued = false
cmds = append(cmds, m.newStatusMessage(stashedStatusMessage))
}
if spinnerVisible && m.showStatusMessage {
m.hideStatusMessage()
} }
// A note was set on a document. This may have happened in the pager so // A note was set on a document. This may have happened in the pager so
@ -572,7 +581,14 @@ func (m stashModel) update(msg tea.Msg) (stashModel, tea.Cmd) {
// Note: mechanical stuff related to stash success is handled in the parent // Note: mechanical stuff related to stash success is handled in the parent
// update function. // update function.
case stashSuccessMsg: case stashSuccessMsg:
cmds = append(cmds, m.newStatusMessage("Stashed!")) m.spinner.Finish()
if m.spinner.Visible() {
// We want to show the 'stashed!' status message, but need to wait
// until the spinner goes away first.
m.stashStatusMessageQueued = true
} else {
cmds = append(cmds, m.newStatusMessage(stashedStatusMessage))
}
// Note: mechanical stuff related to stash failure is handled in the parent // Note: mechanical stuff related to stash failure is handled in the parent
// update function. // update function.
@ -961,7 +977,7 @@ func (m stashModel) view() string {
case stashStateReady: case stashStateReady:
loadingIndicator := " " loadingIndicator := " "
if !m.localOnly() && (!m.loadingDone() || m.spinner.Visible()) { if !m.loadingDone() || m.spinner.Visible() {
loadingIndicator = m.spinner.View() loadingIndicator = m.spinner.View()
} }