fix double-fetch of cred types in launch prompts

This commit is contained in:
Keith Grant 2020-04-09 16:07:06 -07:00
parent af18aa8456
commit 7827a2aedd

View File

@ -24,7 +24,6 @@ function CredentialsStep({ i18n }) {
const [selectedType, setSelectedType] = useState(null);
const history = useHistory();
const isTypeSelected = !!selectedType;
const {
result: types,
error: typesError,
@ -33,13 +32,13 @@ function CredentialsStep({ i18n }) {
} = useRequest(
useCallback(async () => {
const loadedTypes = await CredentialTypesAPI.loadAllTypes();
if (!isTypeSelected && loadedTypes.length) {
if (loadedTypes.length) {
const match =
loadedTypes.find(type => type.kind === 'ssh') || loadedTypes[0];
setSelectedType(match);
}
return loadedTypes;
}, [isTypeSelected]),
}, []),
[]
);