Fix state names and log messages for status changes API.

This commit is contained in:
Igor Mandrigin 2018-03-16 16:08:44 +01:00 committed by Dmitry Shulyak
parent 8e42014671
commit 804fe949f7
4 changed files with 5 additions and 5 deletions

View File

@ -240,7 +240,7 @@ func (api *StatusAPI) ConnectionChange(typ string, expensive bool) {
func (api *StatusAPI) AppStateChange(state string) {
appState, err := ParseAppState(state)
if err != nil {
log.Error("AppStateChange failed, ignoring it:", err)
log.Error("AppStateChange failed, ignoring it.", "err", err)
return // and do nothing
}
api.b.AppStateChange(appState)

View File

@ -15,7 +15,7 @@ func (a AppState) String() string {
// Specific app states
// see https://facebook.github.io/react-native/docs/appstate.html
const (
AppStateForeground = AppState("foreground")
AppStateForeground = AppState("active") // these constant values are kept in sync with React Native
AppStateBackground = AppState("background")
AppStateInactive = AppState("inactive")

View File

@ -15,10 +15,10 @@ func TestParseAppType(t *testing.T) {
}
}
check("foreground", AppStateForeground, false)
check("active", AppStateForeground, false)
check("background", AppStateBackground, false)
check("inactive", AppStateInactive, false)
check(" forEGROUnd ", AppStateForeground, false)
check(" acTIVE ", AppStateForeground, false)
check(" backGROUND ", AppStateBackground, false)
check(" INACTIVE ", AppStateInactive, false)
check("", AppStateInvalid, true)

View File

@ -239,7 +239,7 @@ func (b *StatusBackend) ConnectionChange(state ConnectionState) {
// AppStateChange handles app state changes (background/foreground).
func (b *StatusBackend) AppStateChange(state AppState) {
log.Info("App State changed: %s", state)
log.Info("App State changed.", "new-state", state)
// TODO: put node in low-power mode if the app is in background (or inactive)
// and normal mode if the app is in foreground.