Skip to content

Commit 541f56c

Browse files
authored
fix: add CLOUD check and cleanup function to DynamicFluxFunctionsToolbar to prevent memory leak (#4376)
1 parent af4b080 commit 541f56c

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

src/flows/pipes/RawFluxEditor/view.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import 'src/flows/pipes/RawFluxEditor/style.scss'
3939

4040
// Utils
4141
import {event} from 'src/cloud/utils/reporting'
42+
import {CLOUD} from 'src/shared/constants'
4243
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
4344

4445
const FluxMonacoEditor = lazy(() =>
@@ -98,7 +99,7 @@ const Query: FC<PipeProp> = ({Context}) => {
9899
} else {
99100
event('Flux Panel (Notebooks) - Toggle Functions - On')
100101
show(id)
101-
if (isFlagEnabled('fluxDynamicDocs')) {
102+
if (CLOUD && isFlagEnabled('fluxDynamicDocs')) {
102103
showSub(<DynamicFunctions onSelect={injectIntoEditor} />)
103104
} else {
104105
showSub(<Functions onSelect={injectIntoEditor} />)

src/timeMachine/components/FluxToolbar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import FluxToolbarTab from 'src/timeMachine/components/FluxToolbarTab'
1111
import {FluxToolbarFunction} from 'src/types'
1212

1313
// Utils
14+
import {CLOUD} from 'src/shared/constants'
1415
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
1516

1617
interface Props {
@@ -30,7 +31,7 @@ const FluxToolbar: FC<Props> = ({onInsertFluxFunction, onInsertVariable}) => {
3031
let activeToolbar
3132

3233
if (activeTab === 'functions') {
33-
if (isFlagEnabled('fluxDynamicDocs')) {
34+
if (CLOUD && isFlagEnabled('fluxDynamicDocs')) {
3435
activeToolbar = (
3536
<DynamicFluxFunctionsToolbar
3637
onInsertFluxFunction={onInsertFluxFunction}

src/timeMachine/components/TimeMachineFluxEditor.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
generateImport,
2222
} from 'src/timeMachine/utils/insertFunction'
2323
import {event} from 'src/cloud/utils/reporting'
24+
import {CLOUD} from 'src/shared/constants'
2425
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
2526
import {getFluxExample} from 'src/shared/utils/fluxExample'
2627

@@ -133,7 +134,7 @@ const TimeMachineFluxEditor: FC = () => {
133134
return
134135
}
135136
const {text, range} = getFluxTextAndRange(
136-
isFlagEnabled('fluxDynamicDocs')
137+
CLOUD && isFlagEnabled('fluxDynamicDocs')
137138
? getFluxExample(func as FluxFunction)
138139
: func
139140
)

src/timeMachine/components/dynamicFluxFunctionsToolbar/FluxFunctionsToolbar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const DynamicFluxFunctionsToolbar: FC<Props> = (props: Props) => {
4848

4949
if (fluxFunctions.length === 0) {
5050
await getFluxPackages()
51-
setFluxLoadingState(RemoteDataState.Done)
5251
}
5352
setFluxLoadingState(RemoteDataState.Done)
5453
} catch (err) {
@@ -57,6 +56,9 @@ const DynamicFluxFunctionsToolbar: FC<Props> = (props: Props) => {
5756
}
5857
}
5958
getFluxFuncs()
59+
return () => {
60+
setFluxLoadingState(RemoteDataState.NotStarted)
61+
}
6062
}, []) // eslint-disable-line react-hooks/exhaustive-deps
6163

6264
useEffect(() => {

0 commit comments

Comments
 (0)