feat: add 'r' to refresh list and document (#624)

* feat: add 'r' to refresh list

closes #416

Co-authored-by: Dieter Eickstaedt <eickstaedt@deicon.de>

* feat: refresh document

Closes #501

Co-authored-by: fedeztk <federicoserranexus@gmail.com>

---------

Co-authored-by: Dieter Eickstaedt <eickstaedt@deicon.de>
Co-authored-by: fedeztk <federicoserranexus@gmail.com>
This commit is contained in:
Carlos Alexandro Becker 2024-07-08 16:15:08 -03:00 committed by GitHub
parent 0a7db86725
commit b1d377237d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 8 deletions

View file

@ -205,6 +205,9 @@ func (m pagerModel) update(msg tea.Msg) (pagerModel, tea.Cmd) {
_ = clipboard.WriteAll(m.currentDocument.Body)
cmds = append(cmds, m.showStatusMessage(pagerStatusMessage{"Copied contents", false}))
case "r":
return m, loadLocalMarkdown(&m.currentDocument)
case "?":
m.toggleHelp()
if m.viewport.HighPerformanceRendering {
@ -330,13 +333,12 @@ func (m pagerModel) statusBarView(b *strings.Builder) {
}
func (m pagerModel) helpView() (s string) {
edit := "e edit this document"
col1 := []string{
"g/home go to top",
"G/end go to bottom",
"c copy contents",
edit,
"e edit this document",
"r reload this document",
"esc back to files",
"q quit",
}

View file

@ -888,7 +888,3 @@ func filterMarkdowns(m stashModel) tea.Cmd {
return filteredMarkdownMsg(filtered)
}
}
func (m *stashModel) loadDocs() tea.Cmd {
return findLocalFiles(*m.common)
}

View file

@ -144,6 +144,7 @@ func (m stashModel) helpView() (string, int) {
appHelp = append(appHelp, "!", "errors")
}
appHelp = append(appHelp, "r", "refresh")
appHelp = append(appHelp, "q", "quit")
// Detailed help

View file

@ -164,7 +164,7 @@ func newModel(cfg Config) tea.Model {
func (m model) Init() tea.Cmd {
cmds := []tea.Cmd{m.stash.spinner.Tick}
cmds = append(cmds, m.stash.loadDocs())
cmds = append(cmds, findLocalFiles(*m.common))
return tea.Batch(cmds...)
}
@ -186,6 +186,11 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
batch := m.unloadDocument()
return m, tea.Batch(batch...)
}
case "r":
if m.state == stateShowStash {
m.stash.markdowns = nil
return m, m.Init()
}
case "q":
var cmd tea.Cmd