Show notification when client got disconnected

This commit is contained in:
Thomas Nordquist
2019-03-04 17:55:47 +01:00
parent 4c84a9b5f6
commit dee1abb1da

View File

@@ -13,6 +13,7 @@ import { MqttOptions, DataSourceState } from '../../../backend/src/DataSource'
import { showTree } from './Tree' import { showTree } from './Tree'
import { TopicViewModel } from '../TopicViewModel' import { TopicViewModel } from '../TopicViewModel'
import { showError } from './Global' import { showError } from './Global'
import { globalActions } from '.';
export const connect = (options: MqttOptions, connectionId: string) => (dispatch: Dispatch<any>, getState: () => AppState) => { export const connect = (options: MqttOptions, connectionId: string) => (dispatch: Dispatch<any>, getState: () => AppState) => {
dispatch(connecting(connectionId)) dispatch(connecting(connectionId))
@@ -41,6 +42,7 @@ const updateHealth = (dataSourceState: DataSourceState) => (dispatch: Dispatch<a
state = 'connecting' state = 'connecting'
} else if (!dataSourceState.connected) { } else if (!dataSourceState.connected) {
state = 'offline' state = 'offline'
dispatch(globalActions.showError('Disconnected from server'))
} else if (dataSourceState.connected) { } else if (dataSourceState.connected) {
state = 'online' state = 'online'
} else { } else {