Skip to content

Commit 30d8303

Browse files
Pull out getModelingStatus method and avoid useMemo
1 parent 70e04a1 commit 30d8303

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

  • extensions/ql-vscode/src/view/data-extensions-editor

extensions/ql-vscode/src/view/data-extensions-editor/MethodRow.tsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ import { extensiblePredicateDefinitions } from "../../data-extensions-editor/pre
1919
import { Mode } from "../../data-extensions-editor/shared/mode";
2020
import { Dropdown } from "../common/Dropdown";
2121
import { MethodClassifications } from "./MethodClassifications";
22-
import { ModelingStatusIndicator } from "./ModelingStatusIndicator";
22+
import {
23+
ModelingStatus,
24+
ModelingStatusIndicator,
25+
} from "./ModelingStatusIndicator";
2326

2427
const ApiOrMethodCell = styled(VSCodeDataGridCell)`
2528
display: flex;
@@ -200,21 +203,12 @@ function ModelableMethodRow(props: Props) {
200203
: undefined;
201204
const showKindCell = predicate?.supportedKinds;
202205

203-
const modificationState = useMemo(() => {
204-
if (modeledMethod) {
205-
if (modifiedSignatures.has(modeledMethod.signature)) {
206-
return "unsaved";
207-
} else if (modeledMethod.type !== "none") {
208-
return "saved";
209-
}
210-
}
211-
return "unmodeled";
212-
}, [modeledMethod, modifiedSignatures]);
206+
const modelingStatus = getModelingStatus(modeledMethod, modifiedSignatures);
213207

214208
return (
215209
<VSCodeDataGridRow>
216210
<ApiOrMethodCell gridColumn={1}>
217-
<ModelingStatusIndicator status={modificationState} />
211+
<ModelingStatusIndicator status={modelingStatus} />
218212
<ExternalApiUsageName {...props} />
219213
{mode === Mode.Application && (
220214
<UsagesButton onClick={jumpToUsage}>
@@ -306,3 +300,17 @@ function sendJumpToUsageMessage(externalApiUsage: ExternalApiUsage) {
306300
location: externalApiUsage.usages[0].url,
307301
});
308302
}
303+
304+
function getModelingStatus(
305+
modeledMethod: ModeledMethod | undefined,
306+
modifiedSignatures: Set<string>,
307+
): ModelingStatus {
308+
if (modeledMethod) {
309+
if (modifiedSignatures.has(modeledMethod.signature)) {
310+
return "unsaved";
311+
} else if (modeledMethod.type !== "none") {
312+
return "saved";
313+
}
314+
}
315+
return "unmodeled";
316+
}

0 commit comments

Comments
 (0)