From 8ee096595c3abee9deea08d7cc0fc824342f25b9 Mon Sep 17 00:00:00 2001 From: Yegor Vialov Date: Sun, 18 Nov 2018 09:47:22 +0200 Subject: [PATCH] Resolves #192 Don't fetch data on every app resume --- lib/main.dart | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 2ff7732..8fe89f5 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -148,14 +148,14 @@ class _MainPageState extends State with WidgetsBindingObserver { StreamSubscription _refreshDataSubscription; StreamSubscription _showErrorSubscription; int _isLoading = 1; - bool _settingsLoaded = false; + //bool _settingsLoaded = false; bool _accountMenuExpanded = false; bool _useLovelaceUI; @override void initState() { super.initState(); - _settingsLoaded = false; + //_settingsLoaded = false; WidgetsBinding.instance.addObserver(this); _homeAssistant = HomeAssistant(); @@ -186,9 +186,10 @@ class _MainPageState extends State with WidgetsBindingObserver { @override void didChangeAppLifecycleState(AppLifecycleState state) { TheLogger.debug("$state"); - if (state == AppLifecycleState.resumed && _settingsLoaded) { + /*if (state == AppLifecycleState.resumed && _settingsLoaded && (_homeAssistant == null || _homeAssistant.entities == null)) { + TheLogger.debug("No data. Fetching..."); _refreshData(); - } + }*/ } _loadConnectionSettings() async { @@ -204,9 +205,9 @@ class _MainPageState extends State with WidgetsBindingObserver { if ((domain == null) || (port == null) || (_password == null) || (domain.length == 0) || (port.length == 0) || (_password.length == 0)) { throw("Check connection settings"); - } else { + }/* else { _settingsLoaded = true; - } + }*/ } _subscribe() {