Skip to content

Commit

Permalink
chore: allow going back instead of quitting directly
Browse files Browse the repository at this point in the history
  • Loading branch information
dhth committed Jan 16, 2025
1 parent d5c39ef commit 21c2e84
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add support for JIRA Cloud installation
- Allow shifting timestamps for worklog entries using h/j/k/l/J/K
- Show time spent on unsynced worklog entries

### Changed

- Save UTC timestamps in the database
- Allow going back views instead of quitting directly
- Improved error handling
- Upgrade to go 1.23.4
- Dependency upgrades
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ General
3 Switch to Synced Worklog List View
<tab> Go to next view/form entry
<shift+tab> Go to previous view/form entry
? Show help view
q/<ctrl+c> Go back/reset filtering/quit
<esc> Cancel form/quit
? Show help view
General List Controls
Expand Down
18 changes: 16 additions & 2 deletions internal/ui/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,18 @@ func (m *Model) getCmdToSaveOrUpdateWL() tea.Cmd {
return cmd
}

func (m *Model) handleEscape() {
func (m *Model) handleEscape() bool {
var quit bool

switch m.activeView {
case issueListView:
quit = true
case wLView:
quit = true
case syncedWLView:
quit = true
case helpView:
quit = true
case editActiveWLView:
m.activeView = issueListView
case saveActiveWLView:
Expand All @@ -135,6 +145,8 @@ func (m *Model) handleEscape() {
m.trackingInputs[i].SetValue("")
}
}

return quit
}

func (m *Model) getCmdToGoForwardsInViews() tea.Cmd {
Expand Down Expand Up @@ -232,8 +244,10 @@ func (m *Model) handleRequestToGoBackOrQuit() bool {
if fs == list.Filtering || fs == list.FilterApplied {
m.worklogList.ResetFilter()
} else {
quit = true
m.activeView = issueListView
}
case syncedWLView:
m.activeView = wLView
case helpView:
m.activeView = m.lastView
default:
Expand Down
4 changes: 3 additions & 1 deletion internal/ui/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ var helpText = fmt.Sprintf(`
3 Switch to Synced Worklog List View
<tab> Go to next view/form entry
<shift+tab> Go to previous view/form entry
? Show help view
q/<ctrl+c> Go back/reset filtering/quit
<esc> Cancel form/quit
? Show help view
`),
helpHeaderStyle.Render("General List Controls"),
helpSectionStyle.Render(`
Expand Down
5 changes: 4 additions & 1 deletion internal/ui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Batch(cmds...)
}
case "esc":
m.handleEscape()
quit := m.handleEscape()
if quit {
return m, tea.Quit
}
case "tab":
viewSwitchCmd := m.getCmdToGoForwardsInViews()
if viewSwitchCmd != nil {
Expand Down

0 comments on commit 21c2e84

Please sign in to comment.