Skip to content

Commit

Permalink
gui: invalidate/refresh ui upon successful login/pairing
Browse files Browse the repository at this point in the history
  • Loading branch information
schnoddelbotz committed Nov 21, 2020
1 parent d14c828 commit 3b48b75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion gui/lights.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ func (a *App) selectLightByID(lightID int) error {
a.selectedLight = newLight
a.topLabel = a.selectedLight.Name
a.ui.float.Value = float32(a.selectedLight.State.Bri)
// FIXME...
// TODO: Fix buttons -- update to current powerstate
a.w.Invalidate()
return nil
}

Expand Down
11 changes: 5 additions & 6 deletions gui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gui

import (
"fmt"
"github.com/spf13/viper"
"log"
"os"
"time"
Expand Down Expand Up @@ -162,15 +161,15 @@ func (a *App) loop() error {

func (a *App) login() {
// TODO: This has zero GUI feedback beyond "please press..." (and dies only via console msg...)
log.Printf("Trying to log in ...")
log.Printf("trying to log in ...")
for a.loggedIn == false {
log.Printf("Retrying login ... ")
log.Printf("retrying login ... ")
// bad. copy-paste from cmd/login.go. fixme.
err := a.ctrl.Login()
if err == nil {
perr := a.ctrl.SavePrefs()
if perr != nil {
log.Fatalf("Pairing success, but unable to save prefs! Error: %s", err)
log.Fatalf("pairing success, but unable to save prefs! Error: %s", err)
}
a.loggedIn = true
lights, err := a.getSortedLampIDs()
Expand All @@ -184,10 +183,10 @@ func (a *App) login() {
if err != nil {
log.Fatalf("unable to select light: %s", err)
}
fmt.Printf("Login succes, saved to: %s\n", viper.ConfigFileUsed())
fmt.Printf("login succes!")
return
}
log.Printf("Still no pairing success, sleeping 2 seconds ...")
log.Printf("still no pairing success, sleeping 2 seconds ...")
time.Sleep(2*time.Second)
}
}
Expand Down

0 comments on commit 3b48b75

Please sign in to comment.