Skip to content

Commit 1f83a81

Browse files
author
Maddie
committed
frontend window fix: websocket refactor, consistent styling
1 parent 9faed30 commit 1f83a81

File tree

7 files changed

+175
-329
lines changed

7 files changed

+175
-329
lines changed

frontend/components/nodes/filter-node/filter-node.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
'use client';
22
import { useGlobalContext } from '@/context/GlobalContext';
33
import { ProcessingConfig } from '@/lib/processing';
4+
5+
const dispatchProcessingConfig = (config: ProcessingConfig) => {
6+
window.dispatchEvent(new CustomEvent('processing-config-update', { detail: config }));
7+
};
48
import { Handle, Position, useReactFlow } from '@xyflow/react';
59
import React from 'react';
610
import ComboBox from './combo-box';
@@ -19,8 +23,7 @@ export default function FilterNode({ id }: FilterNodeProps) {
1923
// Get React Flow instance
2024
const reactFlowInstance = useReactFlow();
2125

22-
// Get data stream status from global context
23-
const { dataStreaming, sendProcessingConfig } = useGlobalContext()
26+
const { dataStreaming } = useGlobalContext();
2427

2528
const buildConfig = (): ProcessingConfig => {
2629
if (!isConnected) {
@@ -136,11 +139,11 @@ export default function FilterNode({ id }: FilterNodeProps) {
136139

137140
React.useEffect(() => {
138141
if (!dataStreaming) return
139-
sendProcessingConfig(buildConfig())
142+
dispatchProcessingConfig(buildConfig())
140143
}, [selectedFilter, lowCutoff, highCutoff, isConnected, dataStreaming])
141144

142145
React.useEffect(() => {
143-
sendProcessingConfig(buildConfig());
146+
dispatchProcessingConfig(buildConfig());
144147
}, []);
145148

146149
return (

frontend/components/nodes/signal-graph-node/signal-graph-node.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Card } from '@/components/ui/card';
22
import { Handle, Position, useReactFlow } from '@xyflow/react';
3-
// import useWebsocket from '@/hooks/useWebsocket';
43
import { useGlobalContext } from '@/context/GlobalContext';
4+
import useNodeData from '@/hooks/useNodeData';
55
import { ArrowUpRight } from 'lucide-react';
66
import React from 'react';
77

@@ -16,9 +16,8 @@ import {
1616
import SignalGraphView from './signal-graph-full';
1717

1818
export default function SignalGraphNode({ id }: { id?: string }) {
19-
// const { renderData } = useWebsocket(20, 10);
20-
21-
const { renderData, dataStreaming } = useGlobalContext();
19+
const { dataStreaming } = useGlobalContext();
20+
const { renderData } = useNodeData(20, 10);
2221

2322
const processedData = renderData;
2423
const reactFlowInstance = useReactFlow();

0 commit comments

Comments
 (0)