Skip to content

Commit

Permalink
fix: refresh tmux and main views after session delete (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
GianlucaP106 authored Sep 4, 2024
1 parent b73384c commit 843bd10
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pkg/ui/github_repo_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (g *githubRepoView) init() {
go func() {
wv := getWorkspacesView()
tv := getTopicsView()
refreshFsAsync()
refreshMainViews()
getMainTabGroup().FocusTabByIndex(0)
wv.focus()
tv.selectTopicByName(a.Topic.Name)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/tmux_pane_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (t *tmuxPaneView) init() {
openToastDialogError(err.Error())
}

refreshTmuxViewsAsync()
refreshTmuxViews()
}, "Are you sure you want to kill this pane?")
}).
Set(gocui.KeyEsc, "Focus window view", func() {
Expand Down
14 changes: 7 additions & 7 deletions pkg/ui/tmux_session_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func (tv *tmuxSessionView) init() {
return
}

refreshTmuxViewsAsync()

refreshTmuxViews()
refreshMainViews()
}
}, "Are you sure you want to delete this session?")
}).
Expand All @@ -112,8 +112,8 @@ func (tv *tmuxSessionView) init() {
return
}

refreshTmuxViewsAsync()
refreshFsAsync()
refreshTmuxViews()
refreshMainViews()
}
}, "Are you sure you want to delete ALL tmux sessions?")
}).
Expand All @@ -129,8 +129,8 @@ func (tv *tmuxSessionView) init() {
return
}

refreshTmuxViewsAsync()
refreshFsAsync()
refreshTmuxViews()
refreshMainViews()
}
}, "Are you sure you want to delete ALL non-external tmux sessions?")
}).
Expand Down Expand Up @@ -208,7 +208,7 @@ func (ts *tmuxSessionView) refresh() {
ts.tableRenderer.FillTable(rows, sessions)
}

func refreshTmuxViewsAsync() {
func refreshTmuxViews() {
go func() {
ts := getTmuxSessionView()
ts.refresh()
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/tmux_window_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (t *tmuxWindowView) init() {
openToastDialogError(err.Error())
}

refreshTmuxViewsAsync()
refreshTmuxViews()
}, "Are you sure you want to kill this window?")
}).
Set(gocui.KeyEsc, "Focus session view", func() {
Expand Down
12 changes: 6 additions & 6 deletions pkg/ui/topic_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ func (tv *topicsView) init() {
openEditorDialog(func(s string) {
tv.search.Set(s)
tv.view.Subtitle = tui.WithSurroundingSpaces("Searching: " + s)
refreshFsAsync()
refreshMainViews()
}, func() {}, "Search", smallEditorSize)
}).
Set(gocui.KeyEsc, "Escape search", func() {
if tv.search.Get() != "" {
tv.search.Set("")
tv.view.Subtitle = ""
refreshFsAsync()
refreshMainViews()
}
}).
Set('a', "Create a topic", func() {
Expand All @@ -101,7 +101,7 @@ func (tv *topicsView) init() {
// This will result in the corresponding topic going to the top
// because we are sorting by modifed time
tv.tableRenderer.SelectRow(0)
refreshFsAsync()
refreshMainViews()
}, func() {}, "Topic name", smallEditorSize)
}).
Set('r', "Rename topic", func() {
Expand All @@ -116,7 +116,7 @@ func (tv *topicsView) init() {
return
}

refreshFsAsync()
refreshMainViews()
}, func() {}, "New topic name", smallEditorSize, t.Name)
}).
Set('s', "Search for a workspace", func() {
Expand Down Expand Up @@ -171,7 +171,7 @@ func (tv *topicsView) init() {
openToastDialogError(err.Error())
}

refreshFsAsync()
refreshMainViews()
}, "Are you sure you want to delete this topic? All its content will be deleted.")
}).
Set('?', "Toggle cheatsheet", func() {
Expand Down Expand Up @@ -200,7 +200,7 @@ func (tv *topicsView) refresh() {
tv.tableRenderer.FillTable(rows, rowValues)
}

func refreshFsAsync() {
func refreshMainViews() {
if !getApi().GlobalConfiguration.Standalone {
go func() {
t := getTopicsView()
Expand Down
4 changes: 2 additions & 2 deletions pkg/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,6 @@ func runAction(f func()) {
tui.Suspend()
f()
tui.Resume()
refreshFsAsync()
refreshTmuxViewsAsync()
refreshMainViews()
refreshTmuxViews()
}
19 changes: 10 additions & 9 deletions pkg/ui/workspace_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (wv *workspacesView) init() {
openToastDialogError(err.Error())
}

refreshFsAsync()
refreshMainViews()
}, func() {}, "Git repo URL", smallEditorSize)
}).
Set('G', "Open browser to git repo", func() {
Expand Down Expand Up @@ -272,7 +272,7 @@ func (wv *workspacesView) init() {
}

tv.tableRenderer.SelectRow(0)
refreshFsAsync()
refreshMainViews()
wv.focus()
},
onSelectDescription: "Move workspace to this topic",
Expand All @@ -299,8 +299,8 @@ func (wv *workspacesView) init() {

// HACK: same as below
tv.tableRenderer.SelectRow(0)
refreshFsAsync()
refreshTmuxViewsAsync()
refreshMainViews()
refreshTmuxViews()
}
}, "Are you sure you want to delete this workspace?")
}).
Expand All @@ -318,8 +318,8 @@ func (wv *workspacesView) init() {

tv.tableRenderer.SelectRow(0)
wv.tableRenderer.SelectRow(0)
refreshTmuxViewsAsync()
refreshFsAsync()
refreshTmuxViews()
refreshMainViews()
}, func() {}, "New workspace name", smallEditorSize, curWorkspace.Name)
}).
Set('e', "Add/change description", func() {
Expand All @@ -331,7 +331,7 @@ func (wv *workspacesView) init() {
openEditorDialog(func(desc string) {
if desc != "" {
getApi().Core.SetDescription(desc, curWorkspace)
refreshFsAsync()
refreshMainViews()
}
}, func() {}, "Description", largeEditorSize)
}).
Expand All @@ -353,7 +353,7 @@ func (wv *workspacesView) init() {
// because we are sorting by modifed time
tv.tableRenderer.SelectRow(0)
wv.tableRenderer.SelectRow(0)
refreshFsAsync()
refreshMainViews()
}, func() {}, "Workspace name ", smallEditorSize)
}).
Set('X', "Kill tmux session", func() {
Expand All @@ -366,7 +366,8 @@ func (wv *workspacesView) init() {
openConfirmationDialog(func(b bool) {
if b {
getApi().Core.DeleteWorkspaceTmuxSession(curWorkspace)
refreshFsAsync()
refreshMainViews()
refreshTmuxViews()
}
}, "Are you sure you want to delete the tmux session?")
}
Expand Down

0 comments on commit 843bd10

Please sign in to comment.