Skip to content

Commit

Permalink
fix: PinPad race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed May 24, 2024
1 parent 1b87545 commit 14367f9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/components/PinPad.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@ const PinPad = ({
const [biometryData, setBiometricData] = useState<IsSensorAvailableResult>();

const handleOnPress = (key: string): void => {
vibrate();
if (key === 'delete') {
if (pin.length !== 0) {
vibrate();
setPin((p) => p.slice(0, -1));
}
setPin((p) => {
return p.length === 0 ? '' : p.slice(0, -1);
});
} else {
if (pin.length !== 4) {
vibrate();
setPin((p) => p + key);
}
setPin((p) => {
return p.length === 4 ? p : p + key;
});
}
};

Expand Down

0 comments on commit 14367f9

Please sign in to comment.