temporarily gettin rid of web sockets
This commit is contained in:
parent
4326ecbd0f
commit
25973506b1
2 changed files with 8 additions and 2 deletions
|
|
@ -1,6 +1,9 @@
|
|||
import { pond } from "protobuf-ts/pond";
|
||||
import { useEffect, useRef, useCallback, useMemo } from "react";
|
||||
|
||||
/** Off by default to reduce server load; set VITE_ENABLE_WEBSOCKETS=true to enable live streams. */
|
||||
const WEBSOCKETS_ENABLED = import.meta.env.VITE_ENABLE_WEBSOCKETS === "true";
|
||||
|
||||
/**
|
||||
* Derives the WebSocket base URL from VITE_APP_API_URL.
|
||||
* Matches the logic in useWebSocket.ts.
|
||||
|
|
@ -98,7 +101,7 @@ export function useDeviceStatusStreams(options: UseDeviceStatusStreamsOptions) {
|
|||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled || !token || deviceIds.length === 0) {
|
||||
if (!WEBSOCKETS_ENABLED || !enabled || !token || deviceIds.length === 0) {
|
||||
wsMapRef.current.forEach((ws) => ws.close(1000, "disabled"));
|
||||
wsMapRef.current.clear();
|
||||
reconnectTimeoutsRef.current.forEach((t) => clearTimeout(t));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import { useEffect, useRef, useCallback } from "react";
|
||||
|
||||
/** Off by default to reduce server load; set VITE_ENABLE_WEBSOCKETS=true to enable live streams. */
|
||||
const WEBSOCKETS_ENABLED = import.meta.env.VITE_ENABLE_WEBSOCKETS === "true";
|
||||
|
||||
/**
|
||||
* Derives the WebSocket base URL from VITE_APP_API_URL.
|
||||
* e.g. "https://api.brandxtech.ca" -> "wss://api.brandxtech.ca"
|
||||
|
|
@ -100,7 +103,7 @@ export function useWebSocket<T>(options: UseWebSocketOptions<T>) {
|
|||
}, [path, token, rate]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!enabled || !token) {
|
||||
if (!WEBSOCKETS_ENABLED || !enabled || !token) {
|
||||
if (wsRef.current) {
|
||||
wsRef.current.close(1000, "disabled");
|
||||
wsRef.current = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue