fixed warnings
This commit is contained in:
parent
a259f419fe
commit
d6590c551d
@ -4,7 +4,7 @@ import * as React from "react";
|
||||
import { Grid, Header, Icon, Item, SemanticICONS } from "semantic-ui-react";
|
||||
|
||||
import { injectState, StateBase } from "@app/state";
|
||||
import { ConnectionState as ConState, SprinklersDevice } from "@common/sprinklers";
|
||||
import { ConnectionState as ConState } from "@common/sprinklers";
|
||||
import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from ".";
|
||||
import "./DeviceView.scss";
|
||||
|
||||
|
@ -5,9 +5,6 @@ import { AppContainer } from "react-hot-loader";
|
||||
import App from "@app/components/App";
|
||||
import { ProvideState, StateBase } from "@app/state";
|
||||
import { WebApiState as StateClass } from "@app/state/web";
|
||||
// import log from "@common/logger";
|
||||
|
||||
// Object.assign(log, { name: "sprinklers3/app", level: "debug" });
|
||||
|
||||
const state: StateBase = new StateClass();
|
||||
state.start();
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { action, observable, when } from "mobx";
|
||||
import { update } from "serializr";
|
||||
import { action, autorun, observable, when } from "mobx";
|
||||
|
||||
import logger from "@common/logger";
|
||||
import { ErrorCode } from "@common/sprinklers/ErrorCode";
|
||||
@ -23,7 +23,7 @@ export class WSSprinklersDevice extends s.SprinklersDevice {
|
||||
super();
|
||||
this.api = api;
|
||||
this._id = id;
|
||||
when(() => api.connectionState.isConnected, () => {
|
||||
when(() => api.connectionState.isConnected || false, () => {
|
||||
this.subscribe();
|
||||
});
|
||||
}
|
||||
@ -73,7 +73,7 @@ export class WebSocketApiClient implements s.ISprinklersApi {
|
||||
private reconnectTimer: number | null = null;
|
||||
|
||||
get connected(): boolean {
|
||||
return this.connectionState.isConnected;
|
||||
return this.connectionState.isConnected || false;
|
||||
}
|
||||
|
||||
constructor(webSocketUrl: string) {
|
||||
@ -126,7 +126,7 @@ export class WebSocketApiClient implements s.ISprinklersApi {
|
||||
const id = this.nextDeviceRequestId++;
|
||||
const data: ws.IDeviceCallRequest = {
|
||||
type: "deviceCallRequest",
|
||||
id, deviceId, data: requestData,
|
||||
requestId: id, deviceId, data: requestData,
|
||||
};
|
||||
const promise = new Promise<requests.Response>((resolve, reject) => {
|
||||
let timeoutHandle: number;
|
||||
@ -236,7 +236,7 @@ export class WebSocketApiClient implements s.ISprinklersApi {
|
||||
}
|
||||
|
||||
private onDeviceCallResponse(data: ws.IDeviceCallResponse) {
|
||||
const cb = this.deviceResponseCallbacks[data.id];
|
||||
const cb = this.deviceResponseCallbacks[data.requestId];
|
||||
if (typeof cb === "function") {
|
||||
cb(data);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ export abstract class SprinklersDevice {
|
||||
@observable sectionRunner: SectionRunner;
|
||||
|
||||
@computed get connected(): boolean {
|
||||
return this.connectionState.isConnected;
|
||||
return this.connectionState.isConnected || false;
|
||||
}
|
||||
|
||||
sectionConstructor: typeof Section = Section;
|
||||
|
@ -21,7 +21,7 @@ export class MqttApiClient implements s.ISprinklersApi {
|
||||
devices: Map<string, MqttSprinklersDevice> = new Map();
|
||||
|
||||
get connected(): boolean {
|
||||
return this.connectionState.isConnected;
|
||||
return this.connectionState.isConnected || false;
|
||||
}
|
||||
|
||||
constructor(mqttUri: string) {
|
||||
|
@ -20,7 +20,7 @@ export interface IDeviceUpdate {
|
||||
|
||||
export interface IDeviceCallResponse {
|
||||
type: "deviceCallResponse";
|
||||
id: number;
|
||||
requestId: number;
|
||||
data: ResponseData;
|
||||
}
|
||||
|
||||
@ -32,6 +32,11 @@ export interface IBrokerConnectionUpdate {
|
||||
export type IServerMessage = IError | IDeviceSubscribeResponse | IDeviceUpdate | IDeviceCallResponse |
|
||||
IBrokerConnectionUpdate;
|
||||
|
||||
export interface IAuthenticateRequest {
|
||||
type: "authenticateRequest";
|
||||
accessToken: string;
|
||||
}
|
||||
|
||||
export interface IDeviceSubscribeRequest {
|
||||
type: "deviceSubscribeRequest";
|
||||
deviceId: string;
|
||||
@ -39,7 +44,7 @@ export interface IDeviceSubscribeRequest {
|
||||
|
||||
export interface IDeviceCallRequest {
|
||||
type: "deviceCallRequest";
|
||||
id: number;
|
||||
requestId: number;
|
||||
deviceId: string;
|
||||
data: any;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ export class WebSocketClient {
|
||||
if (response) {
|
||||
const resData: ws.IDeviceCallResponse = {
|
||||
type: "deviceCallResponse",
|
||||
id: data.id,
|
||||
requestId: data.requestId,
|
||||
data: response,
|
||||
};
|
||||
this.socket.send(JSON.stringify(resData));
|
||||
|
Loading…
x
Reference in New Issue
Block a user