Skip to content

Commit

Permalink
perf: removes 1 of the 2 expensive tx generations on input change
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Oct 20, 2022
1 parent eaea6f8 commit 9042a98
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/app/pages/send-tokens/components/send-form-inner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { HIGH_FEE_AMOUNT_STX } from '@shared/constants';
import { useDrawers } from '@app/common/hooks/use-drawers';
import { AssetWithMeta } from '@app/common/asset-types';
import { isEmpty, isUndefined } from '@shared/utils';
import { isTxSponsored, SendFormValues } from '@app/common/transactions/transaction-utils';
import { SendFormValues } from '@app/common/transactions/transaction-utils';
import { ErrorLabel } from '@app/components/error-label';
import { ShowEditNonceAction } from '@app/components/show-edit-nonce';
import { FeeRow } from '@app/components/fee-row/fee-row';
Expand All @@ -19,7 +19,6 @@ import { AmountField } from '@app/pages/send-tokens/components/amount-field';
import { useSelectedAsset } from '@app/pages/send-tokens/hooks/use-selected-asset';
import { RecipientField } from '@app/pages/send-tokens/components/recipient-field';
import { MemoField } from '@app/pages/send-tokens/components/memo-field';
import { useSendFormUnsignedTxPreviewState } from '@app/store/transactions/transaction.hooks';
import { LoadingRectangle } from '@app/components/loading-rectangle';
import { FeeEstimate } from '@shared/models/fees-types';
import { SendFormSelectors } from '@tests/page-objects/send-form.selectors';
Expand All @@ -36,10 +35,9 @@ export function SendFormInner(props: SendFormInnerProps) {
const { assetError, feeEstimations, onAssetIdSelected, nonce } = props;
const { handleSubmit, values, setValues, errors, setFieldError, validateForm } =
useFormikContext<SendFormValues>();

const { showHighFeeConfirmation, setShowHighFeeConfirmation } = useDrawers();
const { selectedAsset } = useSelectedAsset(values.assetId);
const transaction = useSendFormUnsignedTxPreviewState(values.assetId, values);
const isSponsored = transaction ? isTxSponsored(transaction) : false;
const analytics = useAnalytics();

const onSubmit = useCallback(async () => {
Expand Down Expand Up @@ -101,7 +99,7 @@ export function SendFormInner(props: SendFormInnerProps) {
feeEstimations={feeEstimations}
feeFieldName="fee"
feeTypeFieldName="feeType"
isSponsored={isSponsored}
isSponsored={false}
/>
) : (
<LoadingRectangle height="32px" width="100%" />
Expand Down

0 comments on commit 9042a98

Please sign in to comment.