summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>2019-01-04 00:41:15 +0300
committerIbrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>2019-01-04 00:41:15 +0300
commit9ce00feb165a537799f0172aa3486d27863cd7ed (patch)
tree374f19551ccad9dd74c9f453df78dfed1567bd14
parentasync loading (diff)
downloadgitbatch-9ce00feb165a537799f0172aa3486d27863cd7ed.tar.gz
remove unnecessary code
-rw-r--r--pkg/gui/gui.go37
-rw-r--r--pkg/gui/mainview.go24
2 files changed, 5 insertions, 56 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 120054f..2a9fb8b 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -1,7 +1,6 @@
package gui
import (
- "fmt"
"sync"
"github.com/isacikgoz/gitbatch/pkg/git"
@@ -113,36 +112,7 @@ func (gui *Gui) Run() error {
g.InputEsc = true
g.SetManagerFunc(gui.layout)
- // start an async view apart from this loop to show loading screen
- go func(g_ui *Gui) {
- maxX, maxY := g.Size()
- // TODO: view size can be handled in a more smart way
- v, err := g.SetView(loadingViewFeature.Name, maxX/2-10, maxY/2-1, maxX/2+10, maxY/2+1)
- if err != nil {
- if err != gocui.ErrUnknownView {
- log.Warn("Loading view cannot be created.")
- return
- }
- fmt.Fprintln(v, "Loading...")
- }
- if _, err := g.SetCurrentView(loadingViewFeature.Name); err != nil {
- log.Warn("Loading view cannot be focused.")
- return
- }
- go git.LoadRepositoryEntitiesAsync(g_ui.State.Directories, gui.addRepository)
- // rs, err := git.LoadRepositoryEntities(g_ui.State.Directories)
- // if err != nil {
- // g.Close()
- // log.Fatal(err)
- // return
- // }
- // g_ui.State.Repositories = rs
- // add gui's repositoryUpdated func as an observer to repositories
- // for _, repo := range rs {
- // repo.On(git.RepositoryUpdated, gui.repositoryUpdated)
- // }
- gui.fillMain(g)
- }(gui)
+ go git.LoadRepositoryEntitiesAsync(gui.State.Directories, gui.addRepository)
if err := gui.generateKeybindings(); err != nil {
log.Error("Keybindings could not be created.")
@@ -162,7 +132,7 @@ func (gui *Gui) Run() error {
func (gui *Gui) addRepository(e *git.RepoEntity) {
gui.State.Repositories = append(gui.State.Repositories, e)
e.On(git.RepositoryUpdated, gui.repositoryUpdated)
- e.Refresh()
+ gui.repositoryUpdated(nil)
}
// set the layout and create views with their default size, name etc. values
@@ -175,6 +145,9 @@ func (gui *Gui) layout(g *gocui.Gui) error {
}
v.Title = mainViewFeature.Title
v.Overwrite = true
+ if _, err := gui.setCurrentViewOnTop(g, mainViewFeature.Name); err != nil {
+ return err
+ }
}
if v, err := g.SetView(remoteViewFeature.Name, int(0.55*float32(maxX)), 0, maxX-1, int(0.10*float32(maxY))); err != nil {
if err != gocui.ErrUnknownView {
diff --git a/pkg/gui/mainview.go b/pkg/gui/mainview.go
index 8ee31ba..bcf58ed 100644
--- a/pkg/gui/mainview.go
+++ b/pkg/gui/mainview.go
@@ -9,30 +9,6 @@ import (
log "github.com/sirupsen/logrus"
)
-// this is the initial function for filling the values for the main view. the
-// function waits a separate routine to fill the gui's repository slice
-func (gui *Gui) fillMain(g *gocui.Gui) error {
- g.Update(func(g *gocui.Gui) error {
- v, err := g.View(mainViewFeature.Name)
- if err != nil {
- return err
- }
-
- // if there is still a loading screen we better get rid of it
- if err := g.DeleteView(loadingViewFeature.Name); err != nil {
- return err
- }
- if _, err := gui.setCurrentViewOnTop(g, mainViewFeature.Name); err != nil {
- return err
- }
-
- // Sort by name is default behavior as expected, so it handles initial
- // rendering of the main view
- return gui.sortByName(g, v)
- })
- return nil
-}
-
// refresh the main view and re-render the repository representations
func (gui *Gui) renderMain() error {
gui.mutex.Lock()