Resolves #192 Don't fetch data on every app resume
This commit is contained in:
parent
a8e79c289b
commit
8ee096595c
@ -148,14 +148,14 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
StreamSubscription _refreshDataSubscription;
|
StreamSubscription _refreshDataSubscription;
|
||||||
StreamSubscription _showErrorSubscription;
|
StreamSubscription _showErrorSubscription;
|
||||||
int _isLoading = 1;
|
int _isLoading = 1;
|
||||||
bool _settingsLoaded = false;
|
//bool _settingsLoaded = false;
|
||||||
bool _accountMenuExpanded = false;
|
bool _accountMenuExpanded = false;
|
||||||
bool _useLovelaceUI;
|
bool _useLovelaceUI;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_settingsLoaded = false;
|
//_settingsLoaded = false;
|
||||||
WidgetsBinding.instance.addObserver(this);
|
WidgetsBinding.instance.addObserver(this);
|
||||||
|
|
||||||
_homeAssistant = HomeAssistant();
|
_homeAssistant = HomeAssistant();
|
||||||
@ -186,9 +186,10 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
@override
|
@override
|
||||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||||
TheLogger.debug("$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();
|
_refreshData();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadConnectionSettings() async {
|
_loadConnectionSettings() async {
|
||||||
@ -204,9 +205,9 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
if ((domain == null) || (port == null) || (_password == null) ||
|
if ((domain == null) || (port == null) || (_password == null) ||
|
||||||
(domain.length == 0) || (port.length == 0) || (_password.length == 0)) {
|
(domain.length == 0) || (port.length == 0) || (_password.length == 0)) {
|
||||||
throw("Check connection settings");
|
throw("Check connection settings");
|
||||||
} else {
|
}/* else {
|
||||||
_settingsLoaded = true;
|
_settingsLoaded = true;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
_subscribe() {
|
_subscribe() {
|
||||||
|
Reference in New Issue
Block a user