1
0
mirror of https://gitlab.nic.cz/turris/reforis/foris-js.git synced 2025-07-31 19:53:28 +02:00

Fix lint.

This commit is contained in:
Bogdan Bodnar
2019-08-27 16:09:18 +02:00
parent 18e8e20206
commit c0d742b13b
36 changed files with 620 additions and 831 deletions

View File

@@ -5,7 +5,9 @@
* See /LICENSE for more information.
*/
import { ForisUrls } from "forisUrls";
/* eslint no-console: "off" */
import { ForisURLs } from "forisUrls";
const PROTOCOL = window.location.protocol === "http:" ? "ws" : "wss";
@@ -15,13 +17,13 @@ const URL = process.env.LIGHTTPD
const WAITING_FOR_CONNECTION_TIMEOUT = 500;
export class WebSockets {
export default class WebSockets {
constructor() {
this.ws = new WebSocket(URL);
this.ws.onerror = (e) => {
if (window.location.pathname !== ForisUrls.login) {
if (window.location.pathname !== ForisURLs.login) {
console.error("WS: Error observed, you aren't logged probably.");
window.location.replace(ForisUrls.login);
window.location.replace(ForisURLs.login);
}
console.log(`WS: Error: ${e}`);
};

View File

@@ -7,14 +7,15 @@
import { useEffect, useState } from "react";
export function useWSForisModule(ws, module, action = "update_settings") {
export default function useWSForisModule(ws, module, action = "update_settings") {
const [data, setData] = useState(null);
useEffect(() => {
if (ws && module) {
ws.subscribe(module).bind(module, action, (msg) => {
setData(msg.data);
});
ws.subscribe(module)
.bind(module, action, (msg) => {
setData(msg.data);
});
}
}, [action, module, ws]);