summaryrefslogtreecommitdiffstats
path: root/pkg/gui/layout.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-04-03 15:56:11 +1100
committerJesse Duffield <jessedduffield@gmail.com>2021-04-06 19:34:32 +1000
commit0898a7bb57bc399ff016cea06a0ca35d0bf54d6b (patch)
treebc1a26ea01d493f4661bf8352cf0f1744dbf33ff /pkg/gui/layout.go
parentfafd5234bd7be6916e00712a3a138bf2ee92e99b (diff)
refactor
Diffstat (limited to 'pkg/gui/layout.go')
-rw-r--r--pkg/gui/layout.go51
1 files changed, 35 insertions, 16 deletions
diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go
index a60a137af..6d1c956d3 100644
--- a/pkg/gui/layout.go
+++ b/pkg/gui/layout.go
@@ -152,7 +152,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
branchesView.ContainsList = true
}
- commitFilesView, err := setViewFromDimensions("commitFiles", gui.Contexts.CommitFiles.GetWindowName(), true)
+ commitFilesView, err := setViewFromDimensions("commitFiles", gui.State.Contexts.CommitFiles.GetWindowName(), true)
if err != nil {
if err.Error() != UNKNOWN_VIEW_ERROR_MSG {
return err
@@ -266,23 +266,20 @@ func (gui *Gui) layout(g *gocui.Gui) error {
gui.State.OldInformation = informationStr
}
- if !gui.State.ViewsSetup {
+ if !gui.ViewsSetup {
if err := gui.onInitialViewsCreation(); err != nil {
return err
}
- gui.State.ViewsSetup = true
+ gui.ViewsSetup = true
}
- if gui.g.CurrentView() == nil {
- initialContext := gui.Contexts.Files
- if gui.State.Modes.Filtering.Active() {
- initialContext = gui.Contexts.BranchCommits
- }
-
- if err := gui.pushContext(initialContext); err != nil {
+ if !gui.State.ViewsSetup {
+ if err := gui.onInitialViewsCreationForRepo(); err != nil {
return err
}
+
+ gui.State.ViewsSetup = true
}
for _, listContext := range gui.getListContexts() {
@@ -323,7 +320,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
return gui.resizeCurrentPopupPanel()
}
-func (gui *Gui) onInitialViewsCreation() error {
+func (gui *Gui) onInitialViewsCreationForRepo() error {
gui.setInitialViewContexts()
// hide any popup views. This only applies when we've just switched repos
@@ -331,6 +328,28 @@ func (gui *Gui) onInitialViewsCreation() error {
_, _ = gui.g.SetViewOnBottom(viewName)
}
+ // the status panel is not actually a list context at the moment, so it is excluded
+ // here. Arguably that's quite convenient because it means we're back to starting
+ // in the files panel when landing in a new repo, but when returning from a submodule
+ // we'll be back in the submodules context. This still seems awkward though, and it's
+ // definitely going to break when (if) we make the status context a list context
+ initialContext := gui.currentSideContext()
+ if initialContext == nil {
+ if gui.State.Modes.Filtering.Active() {
+ initialContext = gui.State.Contexts.BranchCommits
+ } else {
+ initialContext = gui.State.Contexts.Files
+ }
+ }
+
+ if err := gui.pushContext(initialContext); err != nil {
+ return err
+ }
+
+ return gui.loadNewRepo()
+}
+
+func (gui *Gui) onInitialViewsCreation() error {
gui.g.Mutexes.ViewsMutex.Lock()
// add tabs to views
for _, view := range gui.g.Views() {
@@ -342,10 +361,6 @@ func (gui *Gui) onInitialViewsCreation() error {
}
gui.g.Mutexes.ViewsMutex.Unlock()
- if err := gui.pushContext(gui.defaultSideContext()); err != nil {
- return err
- }
-
if err := gui.keybindings(); err != nil {
return err
}
@@ -357,5 +372,9 @@ func (gui *Gui) onInitialViewsCreation() error {
gui.showRecentRepos = false
}
- return gui.loadNewRepo()
+ gui.Updater.CheckForNewUpdate(gui.onBackgroundUpdateCheckFinish, false)
+
+ gui.waitForIntro.Done()
+
+ return nil
}