aboutsummaryrefslogtreecommitdiffstats
path: root/termui
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-23 21:24:57 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-23 21:24:57 +0200
commit0514edad1a6ee06902841e0c903fc2a2119b7e95 (patch)
tree104279a8939034ab163cac9bfc124166d001dda7 /termui
parente7648996c8f278d061fe03a5c4d255049da765e5 (diff)
downloadgit-bug-0514edad1a6ee06902841e0c903fc2a2119b7e95.tar.gz
cache: maintain, write and load from disk bug excerpts
Diffstat (limited to 'termui')
-rw-r--r--termui/bug_table.go10
-rw-r--r--termui/show_bug.go8
-rw-r--r--termui/termui.go18
3 files changed, 20 insertions, 16 deletions
diff --git a/termui/bug_table.go b/termui/bug_table.go
index 1158f768..6f83a471 100644
--- a/termui/bug_table.go
+++ b/termui/bug_table.go
@@ -19,14 +19,14 @@ const bugTableInstructionView = "bugTableInstructionView"
const remote = "origin"
type bugTable struct {
- repo cache.RepoCacher
+ repo *cache.RepoCache
allIds []string
- bugs []cache.BugCacher
+ bugs []*cache.BugCache
pageCursor int
selectCursor int
}
-func newBugTable(cache cache.RepoCacher) *bugTable {
+func newBugTable(cache *cache.RepoCache) *bugTable {
return &bugTable{
repo: cache,
pageCursor: 0,
@@ -230,14 +230,14 @@ func (bt *bugTable) doPaginate(allIds []string, max int) error {
nb := minInt(len(allIds)-bt.pageCursor, max)
if nb < 0 {
- bt.bugs = []cache.BugCacher{}
+ bt.bugs = []*cache.BugCache{}
return nil
}
// slice the data
ids := allIds[bt.pageCursor : bt.pageCursor+nb]
- bt.bugs = make([]cache.BugCacher, len(ids))
+ bt.bugs = make([]*cache.BugCache, len(ids))
for i, id := range ids {
b, err := bt.repo.ResolveBug(id)
diff --git a/termui/show_bug.go b/termui/show_bug.go
index 12cb6cf4..48592fc4 100644
--- a/termui/show_bug.go
+++ b/termui/show_bug.go
@@ -19,8 +19,8 @@ const showBugHeaderView = "showBugHeaderView"
const timeLayout = "Jan 2 2006"
type showBug struct {
- cache cache.RepoCacher
- bug cache.BugCacher
+ cache *cache.RepoCache
+ bug *cache.BugCache
childViews []string
mainSelectableView []string
sideSelectableView []string
@@ -29,13 +29,13 @@ type showBug struct {
scroll int
}
-func newShowBug(cache cache.RepoCacher) *showBug {
+func newShowBug(cache *cache.RepoCache) *showBug {
return &showBug{
cache: cache,
}
}
-func (sb *showBug) SetBug(bug cache.BugCacher) {
+func (sb *showBug) SetBug(bug *cache.BugCache) {
sb.bug = bug
sb.scroll = 0
sb.selected = ""
diff --git a/termui/termui.go b/termui/termui.go
index 9894dfb2..91e92f00 100644
--- a/termui/termui.go
+++ b/termui/termui.go
@@ -13,7 +13,7 @@ var errTerminateMainloop = errors.New("terminate gocui mainloop")
type termUI struct {
g *gocui.Gui
gError chan error
- cache cache.RepoCacher
+ cache *cache.RepoCache
activeWindow window
@@ -43,7 +43,11 @@ type window interface {
// Run will launch the termUI in the terminal
func Run(repo repository.Repo) error {
- c := cache.NewRepoCache(repo)
+ c, err := cache.NewRepoCache(repo)
+
+ if err != nil {
+ return err
+ }
ui = &termUI{
gError: make(chan error, 1),
@@ -58,7 +62,7 @@ func Run(repo repository.Repo) error {
initGui(nil)
- err := <-ui.gError
+ err = <-ui.gError
if err != nil && err != gocui.ErrQuit {
return err
@@ -157,7 +161,7 @@ func quit(g *gocui.Gui, v *gocui.View) error {
return gocui.ErrQuit
}
-func newBugWithEditor(repo cache.RepoCacher) error {
+func newBugWithEditor(repo *cache.RepoCache) error {
// This is somewhat hacky.
// As there is no way to pause gocui, run the editor and restart gocui,
// we have to stop it entirely and start a new one later.
@@ -176,7 +180,7 @@ func newBugWithEditor(repo cache.RepoCacher) error {
return err
}
- var b cache.BugCacher
+ var b *cache.BugCache
if err == input.ErrEmptyTitle {
ui.msgPopup.Activate(msgPopupErrorTitle, "Empty title, aborting.")
initGui(nil)
@@ -197,7 +201,7 @@ func newBugWithEditor(repo cache.RepoCacher) error {
}
}
-func addCommentWithEditor(bug cache.BugCacher) error {
+func addCommentWithEditor(bug *cache.BugCache) error {
// This is somewhat hacky.
// As there is no way to pause gocui, run the editor and restart gocui,
// we have to stop it entirely and start a new one later.
@@ -230,7 +234,7 @@ func addCommentWithEditor(bug cache.BugCacher) error {
return errTerminateMainloop
}
-func setTitleWithEditor(bug cache.BugCacher) error {
+func setTitleWithEditor(bug *cache.BugCache) error {
// This is somewhat hacky.
// As there is no way to pause gocui, run the editor and restart gocui,
// we have to stop it entirely and start a new one later.