Skip to content

Commit

Permalink
few more upadtes
Browse files Browse the repository at this point in the history
  • Loading branch information
zerts committed Aug 14, 2024
1 parent 02e961d commit ad9bfdf
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ui/components/SignMessageButton/SignMessageButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const SignMessageButton = React.forwardRef(function SignMessageButton(

// there is a small delay after using a holdable button
// button should be disabled after successful sign to prevent a duplicating call
const disabled = isLoading || isSuccess;
const disabled = isLoading || Boolean(holdToSign && isSuccess);
const title = buttonTitle || 'Sign';

return isDeviceAccount(wallet) ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const SignTransactionButton = React.forwardRef(
buttonTitle?: React.ReactNode;
buttonKind?: ButtonKind;
isLoading?: boolean;
holdToSign: boolean;
holdToSign: boolean | null;
},
ref: React.Ref<SendTxBtnHandle>
) {
Expand Down Expand Up @@ -85,7 +85,8 @@ export const SignTransactionButton = React.forwardRef(

// there is a small delay after using a holdable button
// button should be disabled after successful sign to prevent a duplicating call
const disabled = isLoading || sendTxMutation.isSuccess || disabledAttr;
const disabled =
isLoading || (holdToSign && sendTxMutation.isSuccess) || disabledAttr;
const title = buttonTitle || 'Confirm';

return isDeviceAccount(wallet) ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ function CancelTxContent({
wallet={wallet}
ref={signTxBtnRef}
onClick={() => sendTransaction()}
holdToSign={Boolean(preferences.enableHoldToSignButton)}
holdToSign={preferences.enableHoldToSignButton}
/>
) : null}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export function SpeedUp({
wallet={wallet}
ref={signTxBtnRef}
onClick={() => sendTransaction()}
holdToSign={Boolean(preferences.enableHoldToSignButton)}
holdToSign={preferences.enableHoldToSignButton}
/>
) : null}
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/ui/pages/SendTransaction/SendTransaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ function SendTransactionContent({
tx: ethers.providers.TransactionResponse
) {
if (preferences?.enableHoldToSignButton) {
// small delay to show success state to the user before closing the popup
await wait(500);
}
const windowId = params.get('windowId');
Expand Down Expand Up @@ -809,7 +810,7 @@ function SendTransactionContent({
? 'Proceed Anyway'
: undefined
}
holdToSign={Boolean(preferences.enableHoldToSignButton)}
holdToSign={preferences.enableHoldToSignButton}
/>
) : null}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/ui/pages/SignInWithEthereum/SignInWithEthereum.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function SignInWithEthereum() {
onMutate: () => 'signMessage',
onSuccess: async (signature) => {
if (preferences?.enableHoldToSignButton) {
// small delay to show success state to the user before closing the popup
await wait(500);
}
handleSignSuccess(signature);
Expand Down
3 changes: 2 additions & 1 deletion src/ui/pages/SignMessage/SignMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function SignMessageContent({
onMutate: () => 'signMessage',
onSuccess: async (signature) => {
if (preferences?.enableHoldToSignButton) {
// small delay to show success state to the user before closing the popup
await wait(500);
}
handleSignSuccess(signature);
Expand Down Expand Up @@ -179,7 +180,7 @@ function SignMessageContent({
ref={signMsgBtnRef}
wallet={wallet}
onClick={() => personalSign()}
holdToSign={preferences?.enableHoldToSignButton}
holdToSign={preferences.enableHoldToSignButton}
/>
) : null}
</div>
Expand Down
8 changes: 5 additions & 3 deletions src/ui/ui-kit/Button/HoldableButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ const ButtonElement = <As extends ElementType = 'button'>(
}}
onMouseUp={handleMouseUp}
onKeyDown={(e) => {
e.preventDefault();
if (e.key === 'Enter' && innerState === 'idle') {
handleMouseDown();
if (e.key === 'Enter') {
e.preventDefault();
if (innerState === 'idle') {
handleMouseDown();
}
}
}}
onKeyUp={handleMouseUp}
Expand Down

0 comments on commit ad9bfdf

Please sign in to comment.