Skip to content

Commit

Permalink
feat: add 'r' to refresh list and document (#624)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Jul 8, 2024
1 parent 0a7db86 commit b1d3772
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
8 changes: 5 additions & 3 deletions ui/pager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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",
}
Expand Down
4 changes: 0 additions & 4 deletions ui/stash.go
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,3 @@ func filterMarkdowns(m stashModel) tea.Cmd {
return filteredMarkdownMsg(filtered)
}
}

func (m *stashModel) loadDocs() tea.Cmd {
return findLocalFiles(*m.common)
}
1 change: 1 addition & 0 deletions ui/stashhelp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}

Expand All @@ -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
Expand Down

0 comments on commit b1d3772

Please sign in to comment.