Fix caching

This commit is contained in:
Yegor Vialov
2020-03-15 15:26:03 +00:00
parent 14ce608bbb
commit bc642f81ad
2 changed files with 15 additions and 21 deletions

View File

@ -94,7 +94,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
_showInfoBottomBar(progress: true,);
_subscribe().then((_) {
ConnectionManager().init(loadSettings: true, forceReconnect: true).then((__){
_fetchData();
_fetchData(true);
LocationManager();
StartupUserMessagesManager().checkMessagesToShow();
}, onError: (e) {
@ -107,18 +107,18 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver, Ticker
_hideBottomBar();
_showInfoBottomBar(progress: true,);
ConnectionManager().init(loadSettings: false, forceReconnect: false).then((_){
_fetchData();
_fetchData(false);
}, onError: (e) {
_setErrorState(e);
});
}
_fetchData() async {
await HomeAssistant().fetchDataFromCache().then((_) {
if (_entityToShow != null) {
_entityToShow = HomeAssistant().entities.get(_entityToShow.entityId);
}
});
_fetchData(bool useCache) async {
if (useCache) {
HomeAssistant().fetchDataFromCache().then((_) {
setState((){});
});
}
await HomeAssistant().fetchData().then((_) {
_hideBottomBar();
if (_entityToShow != null) {