Commit 0a36ec15 authored by Vladimir Kiryakov's avatar Vladimir Kiryakov
Browse files

wait for device status one sec before show disconnected status

parent 19607438
import mqtt from 'mqtt';
import {MQTT_CONNECT, MQTT_DISCONNECT} from '../actions/mqtt';
import {connected, disconnected, changeConnectionStatus, pushMessages} from '../actions/mqtt';
import {connected, disconnected, changeConnectionStatus, pushMessages, GATEWAY_DISCONNECTED} from '../actions/mqtt';
import _ from 'lodash';
import config from '../config';
const debounceApply = _.debounce((apply) => {
apply();
}, 1000);
const mqttMiddleware = (function () {
let url = null;
let topic = null;
......@@ -55,6 +59,9 @@ const mqttMiddleware = (function () {
});
}
store.dispatch(changeConnectionStatus(_.get(json, 'status')));
debounceApply(() => {
store.dispatch(changeConnectionStatus(GATEWAY_DISCONNECTED))
});
}
});
} catch (e) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment