From b1d377237d81d8149f6c0dd3c70ddacd2ac2b5c5 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 8 Jul 2024 16:15:08 -0300 Subject: [PATCH] feat: add 'r' to refresh list and document (#624) * feat: add 'r' to refresh list closes #416 Co-authored-by: Dieter Eickstaedt * feat: refresh document Closes #501 Co-authored-by: fedeztk --------- Co-authored-by: Dieter Eickstaedt Co-authored-by: fedeztk --- ui/pager.go | 8 +++++--- ui/stash.go | 4 ---- ui/stashhelp.go | 1 + ui/ui.go | 7 ++++++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/pager.go b/ui/pager.go index 3ed307c..ade9b49 100644 --- a/ui/pager.go +++ b/ui/pager.go @@ -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", } diff --git a/ui/stash.go b/ui/stash.go index 86aeec0..d6849c1 100644 --- a/ui/stash.go +++ b/ui/stash.go @@ -888,7 +888,3 @@ func filterMarkdowns(m stashModel) tea.Cmd { return filteredMarkdownMsg(filtered) } } - -func (m *stashModel) loadDocs() tea.Cmd { - return findLocalFiles(*m.common) -} diff --git a/ui/stashhelp.go b/ui/stashhelp.go index af9c16d..636b751 100644 --- a/ui/stashhelp.go +++ b/ui/stashhelp.go @@ -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 diff --git a/ui/ui.go b/ui/ui.go index bb7703d..6cdfd25 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -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