add bindings for refreshing the peers view

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-07-02 16:56:06 -04:00 committed by Jakub
parent b620ad6ea6
commit febde4aeba
3 changed files with 10 additions and 2 deletions

View File

@ -12,7 +12,7 @@ type rcpResp map[string]interface{}
const host = "127.0.0.1"
const port = 8545
const interval = 5
const interval = 3
var threadDone = make(chan struct{})
@ -71,6 +71,8 @@ func main() {
Binding{gocui.KeyCtrlC, gocui.ModNone, quit},
Binding{gocui.KeyArrowUp, gocui.ModNone, mainView.CursorUp},
Binding{gocui.KeyArrowDown, gocui.ModNone, mainView.CursorDown},
Binding{'r', gocui.ModNone, mainView.Refresh},
Binding{gocui.KeyCtrlL, gocui.ModNone, mainView.Refresh},
Binding{'k', gocui.ModNone, mainView.CursorUp},
Binding{'j', gocui.ModNone, mainView.CursorDown},
Binding{gocui.KeyDelete, gocui.ModNone, mainView.HandleDelete},

View File

@ -68,7 +68,7 @@ func updatePeerCursor(g *gocui.Gui, current int) {
if err := v.SetCursor(cx, current); err != nil {
ox, _ := v.Origin()
if err := v.SetOrigin(ox, current); err != nil {
log.Panicln("unable to scroll")
log.Panicln("unable to scroll:", err)
}
}
}

View File

@ -91,6 +91,12 @@ func (v *ViewController) SetKeybindings(g *gocui.Gui) error {
return nil
}
func (vc *ViewController) Refresh(g *gocui.Gui, v *gocui.View) error {
// TODO propper error handling?
vc.StateCtrl.Fetch()
return nil
}
func (vc *ViewController) CursorUp(g *gocui.Gui, v *gocui.View) error {
// TODO propper error handling?
current := vc.StateCtrl.State.GetData().Current