No mobile_app error handling

This commit is contained in:
estevez-dev 2019-09-03 23:35:33 +03:00
parent 8efeb3da8a
commit 0d2f1cf9aa
2 changed files with 15 additions and 5 deletions

View File

@ -301,8 +301,8 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
_subscribe().then((_) { _subscribe().then((_) {
ConnectionManager().init(loadSettings: true, forceReconnect: true).then((__){ ConnectionManager().init(loadSettings: true, forceReconnect: true).then((__){
_fetchData(); _fetchData();
}, onError: (code) { }, onError: (error) {
_setErrorState(code); _setErrorState(error);
}); });
}); });
} }
@ -315,8 +315,8 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
_showInfoBottomBar(progress: true,); _showInfoBottomBar(progress: true,);
ConnectionManager().init(loadSettings: false, forceReconnect: false).then((_){ ConnectionManager().init(loadSettings: false, forceReconnect: false).then((_){
_fetchData(); _fetchData();
}, onError: (code) { }, onError: (error) {
_setErrorState(code); _setErrorState(error);
}); });
} }
@ -460,10 +460,12 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
_setErrorState(error) { _setErrorState(error) {
if (error is UserError) { if (error is UserError) {
setState(() { setState(() {
_showBottomBar = false;
_userError = error; _userError = error;
}); });
} else { } else {
setState(() { setState(() {
_showBottomBar = false;
_userError = UserError(code: ErrorCode.UNKNOWN); _userError = UserError(code: ErrorCode.UNKNOWN);
}); });
} }

View File

@ -162,8 +162,16 @@ class UserErrorScreen extends StatelessWidget {
)); ));
break; break;
} }
case ErrorCode.NO_MOBILE_APP_COMPONENT: {
errorText = "Looks like mobile_app component is not enabled on your Home Assistant instance. Please add it to your configuration.yaml";
buttons.add(RaisedButton(
onPressed: () => Launcher.launchURLInCustomTab(context: context, url: "https://www.home-assistant.io/components/mobile_app/"),
child: Text("Help"),
));
break;
}
default: { default: {
errorText = "???"; errorText = "There was an error. Code ${this.error.code}";
buttons.add(RaisedButton( buttons.add(RaisedButton(
onPressed: () => _reload(), onPressed: () => _reload(),
child: Text("Reload"), child: Text("Reload"),