@@ -2,12 +2,7 @@ import { makeStyles } from "@material-ui/core/styles"
2
2
import { useMachine } from "@xstate/react"
3
3
import { FC , useEffect , useRef , useState } from "react"
4
4
import { Helmet } from "react-helmet-async"
5
- import {
6
- useLocation ,
7
- useNavigate ,
8
- useParams ,
9
- useSearchParams ,
10
- } from "react-router-dom"
5
+ import { useNavigate , useParams , useSearchParams } from "react-router-dom"
11
6
import { colors } from "theme/colors"
12
7
import { v4 as uuidv4 } from "uuid"
13
8
import * as XTerm from "xterm"
@@ -29,7 +24,6 @@ const TerminalPage: FC<
29
24
readonly renderer ?: XTerm . RendererType
30
25
} >
31
26
> = ( { renderer } ) => {
32
- const location = useLocation ( )
33
27
const navigate = useNavigate ( )
34
28
const styles = useStyles ( )
35
29
const { username, workspace } = useParams ( )
@@ -127,17 +121,19 @@ const TerminalPage: FC<
127
121
// the reconnection token and workspace name found
128
122
// from the router.
129
123
useEffect ( ( ) => {
130
- const search = new URLSearchParams ( location . search )
131
- search . set ( "reconnect" , reconnectionToken )
124
+ if ( searchParams . get ( "reconnect" ) === reconnectionToken ) {
125
+ return
126
+ }
127
+ searchParams . set ( "reconnect" , reconnectionToken )
132
128
navigate (
133
129
{
134
- search : search . toString ( ) ,
130
+ search : searchParams . toString ( ) ,
135
131
} ,
136
132
{
137
133
replace : true ,
138
134
} ,
139
135
)
140
- } , [ location . search , navigate , reconnectionToken ] )
136
+ } , [ searchParams , navigate , reconnectionToken ] )
141
137
142
138
// Apply terminal options based on connection state.
143
139
useEffect ( ( ) => {
0 commit comments