Resolves #128 Enpty settings change issue
This commit is contained in:
parent
c19a0511a6
commit
5bf063969b
@ -113,21 +113,16 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
_settingsSubscription = eventBus.on<SettingsChangedEvent>().listen((event) {
|
_settingsSubscription = eventBus.on<SettingsChangedEvent>().listen((event) {
|
||||||
TheLogger.log("Debug","Settings change event: reconnect=${event.reconnect}");
|
TheLogger.log("Debug","Settings change event: reconnect=${event.reconnect}");
|
||||||
if (event.reconnect) {
|
if (event.reconnect) {
|
||||||
_homeAssistant.disconnect().then((_){
|
_initialLoad();
|
||||||
_loadConnectionSettings().then((b){
|
|
||||||
_refreshData();
|
|
||||||
}, onError: (_) {
|
|
||||||
setState(() {
|
|
||||||
_isLoading = 2;
|
|
||||||
});
|
|
||||||
_showErrorSnackBar(message: _, errorCode: 5);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_initialLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _initialLoad() {
|
||||||
_loadConnectionSettings().then((_){
|
_loadConnectionSettings().then((_){
|
||||||
_createConnection();
|
_subscribe();
|
||||||
|
_refreshData();
|
||||||
}, onError: (_) {
|
}, onError: (_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = 2;
|
_isLoading = 2;
|
||||||
@ -161,8 +156,7 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_createConnection() {
|
_subscribe() {
|
||||||
_refreshData();
|
|
||||||
if (_stateSubscription == null) {
|
if (_stateSubscription == null) {
|
||||||
_stateSubscription = eventBus.on<StateChangedEvent>().listen((event) {
|
_stateSubscription = eventBus.on<StateChangedEvent>().listen((event) {
|
||||||
setState(() {
|
setState(() {
|
||||||
@ -203,9 +197,9 @@ class _MainPageState extends State<MainPage> with WidgetsBindingObserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_refreshData() async {
|
_refreshData() async {
|
||||||
_hideErrorSnackBar();
|
|
||||||
_homeAssistant.updateConnectionSettings(_apiEndpoint, _apiPassword, _authType);
|
_homeAssistant.updateConnectionSettings(_apiEndpoint, _apiPassword, _authType);
|
||||||
setState(() {
|
setState(() {
|
||||||
|
_hideErrorSnackBar();
|
||||||
_isLoading = 1;
|
_isLoading = 1;
|
||||||
});
|
});
|
||||||
await _homeAssistant.fetch().then((result) {
|
await _homeAssistant.fetch().then((result) {
|
||||||
|
Reference in New Issue
Block a user