Fix fetch timeout on app start

This commit is contained in:
estevez 2018-10-03 15:25:01 +03:00
parent e0d35d07dc
commit 77c5f80c13
2 changed files with 7 additions and 3 deletions

View File

@ -34,7 +34,7 @@ part 'badge_class.dart';
EventBus eventBus = new EventBus(); EventBus eventBus = new EventBus();
const String appName = "HA Client"; const String appName = "HA Client";
const appVersion = "0.2.4"; const appVersion = "0.2.5";
String homeAssistantWebHost; String homeAssistantWebHost;
@ -100,6 +100,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
StreamSubscription _serviceCallSubscription; StreamSubscription _serviceCallSubscription;
StreamSubscription _showEntityPageSubscription; StreamSubscription _showEntityPageSubscription;
bool _isLoading = true; bool _isLoading = true;
bool _settingsLoaded = false;
Map<String, Color> _badgeColors = { Map<String, Color> _badgeColors = {
"default": Color.fromRGBO(223, 76, 30, 1.0), "default": Color.fromRGBO(223, 76, 30, 1.0),
@ -109,6 +110,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_settingsLoaded = false;
WidgetsBinding.instance.addObserver(this); WidgetsBinding.instance.addObserver(this);
_homeAssistant = HomeAssistant(); _homeAssistant = HomeAssistant();
@ -144,7 +146,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
@override @override
void didChangeAppLifecycleState(AppLifecycleState state) { void didChangeAppLifecycleState(AppLifecycleState state) {
TheLogger.log("Debug","$state"); TheLogger.log("Debug","$state");
if (state == AppLifecycleState.resumed) { if (state == AppLifecycleState.resumed && _settingsLoaded) {
_refreshData(); _refreshData();
} }
} }
@ -161,6 +163,8 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
if ((domain == null) || (port == null) || (_apiPassword == null) || if ((domain == null) || (port == null) || (_apiPassword == null) ||
(domain.length == 0) || (port.length == 0) || (_apiPassword.length == 0)) { (domain.length == 0) || (port.length == 0) || (_apiPassword.length == 0)) {
throw("Check connection settings"); throw("Check connection settings");
} else {
_settingsLoaded = true;
} }
} }

View File

@ -1,7 +1,7 @@
name: hass_client name: hass_client
description: Home Assistant Android Client description: Home Assistant Android Client
version: 0.2.4+26 version: 0.2.5+27
environment: environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0" sdk: ">=2.0.0-dev.68.0 <3.0.0"