mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 09:36:27 +00:00
firmware/installPybricksDialog: only call useFirmware() once
We were unpacking the firmware twice. Instead, we should only call useFirmware() once and pass the results as props.
This commit is contained in:
committed by
David Lechner
parent
a841562c6c
commit
63597e4b88
@@ -321,8 +321,9 @@ const SelectHubPanel: React.VoidFunctionComponent<SelectHubPanelProps> = ({
|
||||
};
|
||||
|
||||
type AcceptLicensePanelProps = {
|
||||
hubType: Hub;
|
||||
licenseAccepted: boolean;
|
||||
firmwareData: FirmwareData | undefined;
|
||||
firmwareError: Error | undefined;
|
||||
isCustomFirmwareRequested: boolean;
|
||||
customFirmwareData: FirmwareData | undefined;
|
||||
customFirmwareError: Error | undefined;
|
||||
@@ -330,14 +331,14 @@ type AcceptLicensePanelProps = {
|
||||
};
|
||||
|
||||
const AcceptLicensePanel: React.VoidFunctionComponent<AcceptLicensePanelProps> = ({
|
||||
hubType,
|
||||
licenseAccepted,
|
||||
firmwareData,
|
||||
firmwareError,
|
||||
isCustomFirmwareRequested,
|
||||
customFirmwareData,
|
||||
customFirmwareError,
|
||||
onLicenseAcceptedChanged,
|
||||
}) => {
|
||||
const { firmwareData, firmwareError } = useFirmware(hubType);
|
||||
const i18n = useI18n();
|
||||
|
||||
const selectedFirmwareData = isCustomFirmwareRequested
|
||||
@@ -447,7 +448,7 @@ export const InstallPybricksDialog: React.VoidFunctionComponent = () => {
|
||||
const [hubName, setHubName] = useState('');
|
||||
const [licenseAccepted, setLicenseAccepted] = useState(false);
|
||||
const [hubType] = useHubPickerSelectedHub();
|
||||
const { firmwareData } = useFirmware(hubType);
|
||||
const { firmwareData, firmwareError } = useFirmware(hubType);
|
||||
const [customFirmwareZip, setCustomFirmwareZip] = useState<File>();
|
||||
const { isCustomFirmwareRequested, customFirmwareData, customFirmwareError } =
|
||||
useCustomFirmware(customFirmwareZip);
|
||||
@@ -495,8 +496,9 @@ export const InstallPybricksDialog: React.VoidFunctionComponent = () => {
|
||||
title={i18n.translate('licensePanel.title')}
|
||||
panel={
|
||||
<AcceptLicensePanel
|
||||
hubType={selectedHubType}
|
||||
licenseAccepted={licenseAccepted}
|
||||
firmwareData={firmwareData}
|
||||
firmwareError={firmwareError}
|
||||
isCustomFirmwareRequested={isCustomFirmwareRequested}
|
||||
customFirmwareData={customFirmwareData}
|
||||
customFirmwareError={customFirmwareError}
|
||||
|
||||
Reference in New Issue
Block a user