~adnano/astronaut

913d8e0f12d3d4aa7477bf8b5b3d735169d265af — Adnan Maolood 2 months ago e81d322
tab: Fix deadlock in Back and Forward methods
1 files changed, 6 insertions(+), 3 deletions(-)

M tab.go
M tab.go => tab.go +6 -3
@@ 200,7 200,7 @@ func (t *Tab) Back() {
		t.page--
		t.updateStatus()
	} else {
		t.Error(errors.New("Already at beginning of history"))
		t.errorLocked(errors.New("Already at beginning of history"))
	}
}



@@ 212,7 212,7 @@ func (t *Tab) Forward() {
		t.page++
		t.updateStatus()
	} else {
		t.Error(errors.New("Already at end of history"))
		t.errorLocked(errors.New("Already at end of history"))
	}
}



@@ 287,8 287,11 @@ func (t *Tab) Do(req *gemini.Request) {
func (t *Tab) Error(err error) {
	t.mu.Lock()
	defer t.mu.Unlock()
	t.status.Clear()
	t.errorLocked(err)
}

func (t *Tab) errorLocked(err error) {
	t.status.Clear()
	msg := fmt.Sprintf("error: %s", err.Error())
	// TODO: Show human friendly errors
	t.status.Error(msg)