Skip to content

Commit 5b01199

Browse files
committed
fix reconnection issues
1 parent 68c0832 commit 5b01199

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "arduino-serial-plotter-webapp",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"dependencies": {},
55
"license": "AGPL",
66
"scripts": {

src/App.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export default function App() {
5454
setConfig({ ...config, ...message.data });
5555
}
5656
},
57-
[setConfig, config]
57+
// eslint-disable-next-line react-hooks/exhaustive-deps
58+
[config, setConfig]
5859
);
5960

6061
// as soon as the wsPort is set, create a websocket connection
@@ -63,6 +64,7 @@ export default function App() {
6364
return;
6465
}
6566

67+
console.log(`opening ws connection on localhost:${config?.wsPort}`);
6668
websocket.current = new WebSocket(`ws://localhost:${config?.wsPort}`);
6769
websocket.current.onmessage = (res: any) => {
6870
const message: SerialPlotter.Protocol.Message = JSON.parse(res.data);
@@ -71,9 +73,11 @@ export default function App() {
7173
const wsCurrent = websocket.current;
7274

7375
return () => {
76+
console.log("closing ws connection");
7477
wsCurrent.close();
7578
};
76-
}, [config?.wsPort, onMiddlewareMessage]);
79+
// eslint-disable-next-line react-hooks/exhaustive-deps
80+
}, [config?.wsPort]);
7781

7882
// at bootstrap read params from the URL
7983
useEffect(() => {
@@ -99,7 +103,7 @@ export default function App() {
99103
data: urlSettings,
100104
});
101105
}
102-
}, [onMiddlewareMessage, config]);
106+
}, [config, onMiddlewareMessage]);
103107

104108
// If in "generate" mode, create fake data
105109
useEffect(() => {

src/Legend.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function Legend({
3737
if (scrollRef.current.getScrollLeft() === 0) setShowScrollLeft(false);
3838
if (
3939
scrollRef.current.getScrollLeft() +
40-
scrollRef.current.getClientWidth() ===
40+
scrollRef.current.getClientWidth() >=
4141
scrollRef.current.getScrollWidth()
4242
)
4343
setShowScrollRight(false);
@@ -86,7 +86,10 @@ export function Legend({
8686
<Scrollbars
8787
ref={scrollRef}
8888
className="scrollbar"
89-
hideTracksWhenNotNeeded={true}
89+
renderTrackVertical={(props) => <div {...props} className="track" />}
90+
renderTrackHorizontal={(props) => (
91+
<div {...props} className="track" />
92+
)}
9093
style={{
9194
height: "29px",
9295
marginRight: "17px",

src/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ body {
123123
scrollbar-width: none;
124124
scroll-behavior: smooth;
125125
bottom: -10px;
126+
margin-bottom: 16px;
126127

127128
&::-webkit-scrollbar {
128129
display: none;

0 commit comments

Comments
 (0)